ASPit - Totally ASP JSit - Totally JavaScript
Search PHPit

Use this textbox to search for articles on PHPit. Seperate keywords with a space.

Advertisements

Check if files exists

With this short codesnippet you can easily check if a file exists on your server.

$filename '/path/to/foo.txt';

if (
file_exists($filename)) {
    print 
"The file $filename exists";
} else {
    print 
"The file $filename does not exist";
}
?> 

3 Responses to “Check if files exists”

  1. quince Says:

    I add an error doc to this script instead of printing the result and it worked great.

    Thanks.

  2. Lazer Says:

    I need a short code to check before an image is loaded if the file exists on th server.
    If it does, the image will be loaded. (the fuks name is stored in a javascript variable rt)
    If it does not, another image name “nopic.jpg” will be loaded.
    How do I do it?
    I have no knowlage with PHP.
    PLease help.

  3. Lazer Says:

    OOps, type missmatch….should have been the FILE name in stored…
    Sorry.

Leave a Reply