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.