Click to See Complete Forum and Search --> : $_FILES upload error


kredd
07-02-2007, 10:18 AM
hello, not sure if the code below is the exact cause but i'll start with it before unloading a ton of code :) the code below works fine on a pc in IE7/FF2 but it breaks on a mac SF/FF...i *think* it might be the image/type????



($_FILES["uploaded_file"]["type"] == "image/jpeg")




if (($ext == "jpg") && ($_FILES["uploaded_file"]["type"] == "image/jpeg") && ($_FILES["uploaded_file"]["size"] < $max_size) || ($ext == "jpg") && ($_FILES["uploaded_file"]["type"] == "image/pjpeg") && ($_FILES["uploaded_file"]["size"] < $max_size)) {

do some stuff here....

} ELSE {

echo "Error: A problem occurred during file upload!";
print_r($_FILES['uploaded_file']);
}


the ELSE portion is firing and this is the error i get:


Error: A problem occurred during file upload!Array ( [name] => DSC_0360.JPG [type] => image/jpeg [tmp_name] => /tmp/phpmABpxj [error] => 0 [size] =>
2330313 )


at first FF on my pc was breaking and i added the "OR" statement to the "if" statement so it would test for 'jpeg' AND 'pjpeg'...then FF started working - that's why i'm thinking it may be breaking the mac browsers too...

any ideas? i may be barking up the wrong tree :o

thanks!

temp.user123
07-02-2007, 10:43 AM
So, before the if statement, do this to see what you're getting:

echo 'type="' . $_FILES["uploaded_file"]["type"] . '"<br>' . "\n";

kredd
07-02-2007, 08:09 PM
i don't think the image is the prob, but i tried uploading the same photo and i got this...

IE7 says this: type="image/pjpeg"

FF2 says this: type="image/jpeg"

the error msg in my orig post is from a safari browser and its saying, just like FF2: type="image/jpeg"

i think its the mac browser but i don't know how it could be. if it was php or the image shouldn't the $_FILE Array ( [error] => 0) be something besides 0?

temp.user123
07-02-2007, 10:46 PM
Well, compare the rest of what is in there:

echo 'FILES: <pre>';
print_r $_FILES;
echo '</pre><br>' . "\n";

kredd
07-03-2007, 11:48 AM
i already have. they all say the same thing. i posted the $_FILES array in my first post:


Array (
[name] => DSC_0360.JPG
[type] => image/jpeg
[tmp_name] => /tmp/phpmABpxj
[error] => 0
[size] => 2330313 )


that's what Safari tells me when the 'IF' breaks. PC IE7/FF2 say the same thing as well, only they actually work. :confused:

temp.user123
07-03-2007, 11:52 AM
This is the part that is failing:

($ext == "jpg")

What you posted has it in upper case.

kredd
07-05-2007, 04:47 PM
good call...got it working. thanks for the hlp.

temp.user123
07-05-2007, 07:55 PM
You're welcome.