getimagesize() not working between Dirs!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rxsid
Forum Commoner
Posts: 82
Joined: Thu Aug 29, 2002 12:04 am

getimagesize() not working between Dirs!

Post 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.
PAW Projects
Forum Commoner
Posts: 30
Joined: Tue Jun 15, 2004 7:43 am
Contact:

Post 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..
rxsid
Forum Commoner
Posts: 82
Joined: Thu Aug 29, 2002 12:04 am

Post 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?
rxsid
Forum Commoner
Posts: 82
Joined: Thu Aug 29, 2002 12:04 am

RESOLVED!

Post 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!
Post Reply