Thursday, 29 May 2008

testing for File with file_exists

in my code I have a check to see if there is a thumbnail image if not I then resize the image and make a thumbnail. Before running I need to check that I have a big image to crop in the first place.
I do this with
if (!file_exists($thumbnailImg) && file_exists($imgFull))

however the argument file_exists($imgFull) comes back as TRUE even if the folder exists.
one way to get around this problem would be on the command

$imgFull = $pathFull.$img1;
I could check on $img and if it doesn't exist fill it with a value that deliberatly gives an error

if (strlen($img1) > 4){ // counts that $img1 has more than 4 characters ie 1.gif has 5

$imgFull = $pathFull.$img1;}
{$imgFull = $pathFull.'error.txt';}

you can check this code working at self catering cornwall .biz

No comments: