What PHP functions can be used to check for the existence of a file before uploading or downloading in PHP?

When uploading or downloading files in PHP, it is important to check if the file already exists to prevent overwriting existing files or encountering errors. Two PHP functions that can be used to check for the existence of a file are file_exists() and is_file(). These functions return a boolean value indicating whether the file exists or not.

// Check if a file exists before uploading or downloading
$file_path = 'path/to/file.txt';

if (file_exists($file_path)) {
    echo 'File exists!';
} else {
    echo 'File does not exist.';
}