PHP posting binary file not working

PHP file upload seems broken on Dreamhost. What do I need to do to get it working? Sample code I got from the web is below, as well as the response for a wget which indicates the file went across successfully, but there is no data in the $_FILES array at all.

[grant]$ wget -S --post-file=testlog -O junk

=> `junk’
Connecting to[]:80… connected.
HTTP request sent, awaiting response…
1 HTTP/1.1 200 OK
2 Date: Thu, 03 Nov 2005 21:19:33 GMT
3 Server: Apache/1.3.33 (Unix) DAV/1.0.3 mod_fastcgi/2.4.2 mod_gzip/ PHP/4.3.10 mod_ssl/2.8.22 OpenSSL/0.9.7e
4 X-Powered-By: PHP/4.3.10
5 Connection: close
6 Content-Type: text/html

$root = realpath($_SERVER['DOCUMENT_ROOT']);
$uploaddir = $root.'/stuff/';
$uploadfile = $uploaddir . $_FILES['userfile']['name'];
echo ($uploadfile);

print "
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
} else {
print "Possible file upload attack! Here's some debugging info:\n";


For all I know, you PHP code works. I haven’t tried it.

What I find interesting is you neglected to mention if the file you specified in the call to wget is formatted properly for the POST method or not.

If you don’t know what I am talking about, you need to read this: RFC 2388 - Returning Values from Forms: multipart/form-data

Otherwise, try using a web browser instead of wget.

:cool: Perl / MySQL / HTML+CSS

Ok - more info. phpinfo() reports that upload_tmp_dir is not set. If it’s not set, then php won’t even bother uploading the file. So Dreamhost is going to have to figure out how to set upload_tmp_dir in php safe mode :P. Anyway, I did try your suggestion and still no luck. Try running the following code which is from
and you’ll see why this is so frustrating…

File upload File upload Send this file: <?PHP

// copy to this directory

// copy the file to the server
if (isset($submit)){

if (!is_uploaded_file ($userfile)){

echo “$userfile_name couldn’t be copied !!”;

// check whether it has been uploaded
if (is_uploaded_file ($userfile)){
move_uploaded_file($userfile,$dir.$userfile_name) ;}

echo “$userfile_name copied succesfully !!”;


It looks like you are correct. My hand-written gallery application is no longer accepting file uploads either. I haven’t used it for a while, so I couldn’t say exactly when it stopped working.

Simon Jessey
Keystone Websites | si-blog

I think uploading is completely broken. I am experiencing the same issue with perl. See

Has this been fixed? I am also experiencing problems. Particularly with getting a value from $_FILES[‘userfile’][‘tmp_name’].


Nothing wrong with uploading. Your Perl code leaves much to be desired.

Try this instead.

:cool: Perl / MySQL / HTML+CSS