From the bottom up
   You have to start some where

Gotcha: file_exists vs. is_file

Sometimes i miss the fine print, today i made minor opps. I was using file_exists() to check for a file, it was returning true even when the file wasn’t there. After awhile i realised that i was using the wrong function to check for the file.

file_exists will return true for file and directories, you should rather use is_file() to check for files.

if( file_exists(UPLOAD_DIR.$_FILES['file_1']['tmp_name']) ){

//WRONG WAY!! THIS WILL STILL RETURN TRUE IF FILE IS NOT THERE
}

if( is_file(UPLOAD_DIR.$_FILES['file_1']['tmp_name']) ){

//CORRECT WAY!!
}

Leave a Reply

You must be logged in to post a comment.