Using File_exists?
| From: | Miller, Terion | Date: | Wed, 03 Jun 2009 18:31:10 +0000 |
| Subject: | Using File_exists? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-293558@lists.php.net to get a copy of this message | ||
I wrote this little script (part of a much much larger one I am working at)
anyways, I am trying to get it to compare a file name from a db to an actual
file in a folder and then tell me if it does or doesn't exist, the problem I
have is that the files do exist, I echo them out, but it says file does not
exist right after that it echos the file for me.... What do I have wrong?
$FileName = $row['Image'];
$ImageName = $row['Image'];
$ImageName = str_replace("/", "", $ImageName);
$FilePath =
"http://localhost:8888/HarrisAutomate/output/WebImagesHiRes/$ImageName";
//$BackupPath =
"http://localhost:8888/HarrisAutomate/WebImagesHiRes/output/backup/";
if (file_exists($FilePath)) {
echo "The file $ImageName exists";
}
else {
echo "The file $ImageName does not exist" . '<br />';
}
$FileName = str_replace("/", "", $FileName);
$FileName = str_replace(".jpg", "", $FileName);
echo ($FileName) . '<br />';
echo '<img src="' . $FilePath .'">' . '<br />';
Thanks guys!
Terion