Hi there,
This has probably been asked a million times but having looked through the PHP manual for the file_exists() function I can't seem to get the right code for what I want to do.
I have a typical scenario of wanting to check for an image files existence before displaying, I have foubd the following code to do this but it always returns false:
What is the best way to find out if an image exists on a remote or local server?
Thanks,
Chromis
This has probably been asked a million times but having looked through the PHP manual for the file_exists() function I can't seem to get the right code for what I want to do.
I have a typical scenario of wanting to check for an image files existence before displaying, I have foubd the following code to do this but it always returns false:
Code:
$imageURL = "http://website.com/images/image1.jpg";
$handle = @fopen($imageURL, 'r');
if ($handle===false) {
echo "image does not exist";
}
else {
echo "image exists";
fclose($handle);
}
Thanks,
Chromis
Comment