I want to check if a img file exist else i use a default img.
but the check i want to use to be sure the image file is there dosnt work.
I have the following code.
$filename = "http://".$_SERVER['SERVER_NAME']."/media/img/".$row['CatNaam'].".jpg";
echo" <img src=\"".$filename."\" alt=\"".$row['CatNaam']."\">";
echo "filename";
if (file_exists($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
the image is there i can see it, but it says that the image does not exist. if i copy the response from echo filename the file is there.
EDIT:
i changed my code to
$filename = "/media/img/".$row['CatNaam'].".jpg";
echo $filename;
echo" <img src=\"".$filename."\" alt=\"".$row['CatNaam']."\">";
echo "<br> $filename <br>";
if (file_exists($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
I can still see the image but now i get a diffrent warning ( i gues this is better then before)
the warning says:
arning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/media/img/Badkraan.jpg) is not within the allowed path(s): (censored) in mydomain/public_html/ve/paginas/producten/zoek.php on line 71 The file /media/img/Badkraan.jpg does not exist
The filepermission is 755