PHP Upload file - Error = 0 but no file uploaded

Hi all,

I'm trying to upload files to a PM G4 (OS X 10.3.9) through a php webpage.

I have my form and it's fine, then the getfile.php page has the following script:

[i]<?php

$uploaddir = '/Library/WebServer/Documents/mysite/Images/Pictures/';
$uploadfile = $uploaddir . basename($_FILES['uploadedFile']['name']);

echo '<pre>';
if (move_uploaded_file($_FILES['uploadedFile']['tmp_name'], $uploadFile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}s

echo 'Here is some more debugging info:';

print_r($_FILES);

print "</pre>";

?>[/i]

and I get the following error:

[i]Possible file upload attack!
Here is some more debugging info:Array
(
[uploadedFile] => Array
(
[name] => test.bmp
[type] => image/x-bmp
[tmp_name] => /var/tmp/phplqhsuj
[error] => 0
[size] => 230454
)

)
[/i]
According to PHP manual:

[i]UPLOAD_ERR_OK

Value: 0; There is no error, the file uploaded with success.[/i]

And yet no file is uploaded to the dir specified.
I have set permissions to 777 for the /tmp/ folder (which is the upload folder set in php.ini) and on the /Images folder.

Has anyone come across something similar before?

Thanks for your help.

PM G4 (Gigabit E) - 400Mhz, 756MB RAM, HD 80GB 7200rpm - iPod Nano Mac OS X (10.3.9) Server version of OS

Posted on Jun 10, 2006 11:50 AM

Reply
1 reply

Jun 11, 2006 1:25 AM in response to Infinite Loop, 1

I was able to solve this, here's how.

First I had a typo in the getfile.php page

$uploadfile = ...

echo '

';
if (move_uploaded_file($_...['...']['...'], $uploadFile))

$uploadfile is NOT the same as $uploadFile. PHP is CASE SENSITIVE.

Then I changed permissions and group on the /var/tmp/ folder to chmod 777 (was 700) and group: www (was wheel).

PM G4 (Gigabit E) - 400Mhz, 756MB RAM, HD 80GB 7200rpm - iPod Nano Mac OS X (10.3.9)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

PHP Upload file - Error = 0 but no file uploaded

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.