View Full Version : how to check if an image is present in the folder?

02-23-2007, 05:15 PM
I have a problem and i will explain it using an example:
my site is http://website.com
i would like to check using PHP if an image picture.jpg exists in a folder in my site. http://website/images/
if it is present, i would like to do { something }
otherwise i would like to do { something else }

I have tried to find if the image exists or not using fopen,
it worked well if the image existed. but if the image is not present, it is giving an error message.

how can i do it?
thank you very much for all replies.

02-23-2007, 05:41 PM
You can use the is_file() (http://us2.php.net/manual/en/function.is-file.php) function.

02-23-2007, 07:37 PM
Can also use file_exists() (http://www.php.net/file_exists)