PHP - file_exists doesn't work even if the file exists in the directory
I am trying to check if a file exists in a directory. When I use this code it works - the image is displayed:
<?php
$imgId=0;
$filename='../uploadedimages/project-'.$item->id.'-'.$imgId;
echo "<img src='".$filename."' ></img>";
?>
When I use the same code with file_exists function, it doesn't work:
<?php
$imgId=0;
$filename='../uploadedimages/project-'.$item->id.'-'.$imgId;
if (file_exists($filename)) {
echo "<img src='".$filename."' ></img>";
}
?>
My question is simple: WTF ??
+3
source to share
2 answers