<?php
$filename = '/path/to/foo.txt';
if (file_exists($filename)) {
    echo "The file $filename exists";
}
?>
That script only checks if a file exists, but how do I do something like this?
<?php
$filename = '/path/to/foo.txt';
if (file doesnt exist) {
    exit("Your file doesn't exist");
}
?>
                As John Conde said, you should negate the file_exists function:
if (!file_exists($filename)) {
    exit("Your file doesn't exist");
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With