I need to be able to tell if an image exists in a directory or not. Given the file name and the directory, how can I tell if it exists?
Thanks!
I need to be able to tell if an image exists in a directory or not. Given the file name and the directory, how can I tell if it exists?
Thanks!
If you need to know more than file_exists() you should look at the stat function... It can tell you if a file exists and if so how big it is, and what type of file it is (and about a dozen other things)...
<?php
$filename = '/path/to/foo.txt';
if (file_exists($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
?>
Source: http://in.php.net/file_exists