I've got a site where users are allowed to upload profile photos. When they do, several versions at different sizes are made, and the database value for 'photo' in the row for their account is incremented by +1. This is so that the file path changes when the image changes, and if they upload a new one, it won't be cached. That's not the problem though.
Before an image is used, I make sure it exists:
Code: Select all
$thumbpath = "propic/" . $value["ID"] . '_' . $value["photo"] . '_a.jpg';
if(file_exists($thumbpath)){
$thumbsize = getimagesize($thumbpath);
}
Now, every so often this results in a big nasty error:
Code: Select all
Warning: getimagesize(propic/200_3_a.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /home/9007/domains/take247.com/html/php/movielisttools.php on line 311
I think this happens when the user screws up the image upload somehow, resulting in a database value for photo (it's looking for the third upload attempt here) and a server which thinks the file exists, but no file. I've checked via URL and FTP, and the file does not exist, yet file_exists says it does. How might I combat this deceptive file_exists() result?