PHP check if image file exists

File_exists does something weird, it does not say if a file exists, it says if path exists. So, to check if it is a file then you should use is_file together with file_exists to know if there is really a file behind the path, otherwise file_exists will return true for any existing path.
Example:

if((is_file($filePath))&&(file_exists($filePath))){
      return true;
}   
else{
      return false;
}

By Keenlio, September 12, 2014

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *


+ 4 = twelve

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>