file_exists($path), $path - path to the file, on the local machine. $TmpName=/images/file1.jpg;
file_exists($DOCUMENT_ROOT.$TmpName); $DOCUMENT_ROOT - PHP environment variable, containing the root path
to website documents on the server machine, and $TmpName - path to the file you checking relative to website root
path. $File="file1.jpg";
$TmpName="/images/".$File;
if(file_exists($DOCUMENT_ROOT.$TmpName)){
print "<b> Oops! The file named
$File already exists</b>";
} else{
print "<b> File named
$File does not exist </b>";
}
When you are usually have to check a file for existence: