Home  »  CodeLibrariesProgrammingSnippetsTechnology   »   Check if File Exists Using PHP

Check if File Exists Using PHP

Posted: May 11, 2022 | by Michael Bright

Use this code snippet to check if file exists using PHP.

$filename = '/path/to/file.txt';

if ( file_exists( $filename ) ) {

   // do something with the file

} else {

   // file does not exist

}

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.