Page 1 of 1

getimagesize() not working between Dirs!

Posted: Thu Jun 17, 2004 8:42 pm
by rxsid
Hi all,

I've got two web forms that handle photo uploads. In one directory ... getimagesize() works fine, in the other... it doesn't:

Directory that it works.
/php/webForm1.html (has action to /php/submitForm.php)
/php/submitForm.php
Directory that doesn't work.
/otherDir/webForm2.html (has action to /php/submitForm.php) //same as above.
the submitForm.php is the script that processes both webForms found in different directory's. Everything else on the form from /otherDir/webForm2.html can be echo'd out fine.
excerpt from submitForm.php script:

Code: Select all

if ($Photo) {
    $photoSize=GetImageSize($Photo);
    if ($photoSize[2]=="1") {
       $photofinal="$uniqueID"."_1".".gif";
       rename (lPhoto,$photofinal);
    } elseif ($photoSize[2]=="2") {
       $photofinal="$uniqueID"."_1".".jpg";
       rename ($Photo,$photofinal); //WORKS HERE WITH 1ST EX.
    } elseif ($photoSize[2]=="3") {
       $photofinal="$uniqueID"."_1".".png";
       rename (lPhoto,$photofinal);
    } else {
       echo "<p> <p>";
       echo "<strong>Your photo must be in .gif, .jpg or .png format only.</strong><p>";
       echo "<a href="javascript:history.back()">Back</a>";
       exit;  //THIS IS WHERE IT'S EXITING EVEN THOUGH THE PHOTO IS TYPE .jpg IN BOTH TEST CASES.
    }
} //End if Photo.
submitForm.php has 775 permissions.

I think it has to do with the fact that the file is uploaded to forms in the two different dir's. both dirs have 755 permissions.
But why would one work and the other not?

Any ideas?

Thanks.

Posted: Fri Jun 18, 2004 3:52 am
by PAW Projects
Throw an

Code: Select all

<?
elseif (!file_exists($Photo)) {
echo 'File: <b>'.$Photo.'</b> does not exist';
}
?>
in there, and see what it returns..

Posted: Sat Jun 19, 2004 12:11 am
by rxsid
thanks for the reply Paw.

with that in place, I'm getting:

File: C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\Sample Pictures\\Water lilies.jpg does not exist

when trying to upload some image from that second dir. from the other dir...it still works.

how could it not exist...if it found something?

RESOLVED!

Posted: Sat Jun 19, 2004 7:17 pm
by rxsid
ok...as usual for me, it's something trivial.

the problem was that the 2nd form didn't have:
enctype="multipart/form-data"
now that that's in the form tag...it works as it should.

problem solved!