tags:

views:

548

answers:

2

Hi

I am running Ubuntu8.041. Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.3 with Suhosin-Patch configured

Can't get file uploading to work at all. Have tested locally on the Ubuntu box... and from my Vista Box. Ubuntu is running inside VMWare on the Vista box.

Here is uploadTestBrowse.php

<?php
?>
<form enctype="multipart/form-data" action="uploadTestBrowse.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
<input type="file" name="fileName" /> <br><br>
<input type="submit" value="Upload Images"/> 
</form>

Here is uploadTestSubmit.php

<?php
error_reporting(E_ALL|E_STRICT);  

$uploaddir = "var/www/ig/images/";
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
    echo "Success.\n";
} else {
    echo "Failure.\n";
}

echo 'Here is some more debugging info:';
print_r($_FILES);
?>

Here is the output of uploadTestSubmit.php

Notice: Undefined index: userfile in /var/www/ig/admin/uploadTestSubmit.php on line 5

Notice: Undefined index: userfile in /var/www/ig/admin/uploadTestSubmit.php on line 7 Failure. Here is some more debugging info:Array ( [fileName] => Array ( [name] => aq.jpg [type] => image/pjpeg [tmp_name] => /tmpUpload/phpMBwMi9 [error] => 0 [size] => 10543 ) )

php.ini file_uploads = On upload_max_filesize = 2M upload_tmp_dir = /tmpUpload

I've chmod -R 777 tmpUpload

I can never see any files in tmpUpload

Apache2 error log not showing anything

Apache2 access log showing: 192.168.21.1 - - [06/Dec/2008:13:13:09 +1300] "GET /ig/admin/uploadTestBrowse.php?=PHPE9568F35-D428-11d2-A769-00AA001ACF42 HTTP/1.1" 200 2146 "http://192.168.21.128/ig/admin/uploadTestBrowse.php" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30618)"

+1  A: 

This may not be the answer to your problem, but I'm noticing you're missing the / in front of var/www/...

It should be: "/var/www/ig/images/"

My first suggestion would be to change that and give it another go.

Lorren Biffin
+1  A: 

Your uploadTestBrowse.php and uploadTestSubmit.php don't match. Different names in action and upload fields.

stesch
Many thanks stesch.. much appreciated
Dave