In PHP, you can use the file_exists()
function to check if a file exists. This function returns true
if the file exists, and false
otherwise.
Here is an example of how to use file_exists()
to check if a file exists:
$filePath = 'path/to/file.ext';
if (file_exists($filePath)) {
echo 'File exists!';
} else {
echo 'File does not exist.';
}
In the above example, replace 'path/to/file.ext'
with the actual path and filename of the file you want to check. The function will return true
and display "File exists!" if the file exists. Otherwise, it will return false
and display "File does not exist."