Check if image file exist
<p>I want to check if a img file exist else i use a default img.</p>

<p>but the check i want to use to be sure the image file is there dosnt work.</p>

<p>I have the following code.</p>

<pre><code>$filename = "http://".$_SERVER['SERVER_NAME']."/media/img/".$row['CatNaam'].".jpg";
        echo"  &lt;img src=\"".$filename."\" alt=\"".$row['CatNaam']."\"&gt;";

        echo "filename";

        if (file_exists($filename)) {
            echo "The file $filename exists";
        } else {
            echo "The file $filename does not exist";
        }
</code></pre>

<p>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.</p>

<p>EDIT:</p>

<p>i changed my code to </p>

<pre><code>$filename = "/media/img/".$row['CatNaam'].".jpg";
        echo $filename;
        echo"  &lt;img src=\"".$filename."\" alt=\"".$row['CatNaam']."\"&gt;";


         echo "&lt;br&gt; $filename &lt;br&gt;";
        if (file_exists($filename)) {
            echo "The file $filename exists";
        } else {
            echo "The file $filename does not exist";
        }
</code></pre>

<p>I can still see the image but now i get a diffrent warning ( i gues this is better then before)</p>

<p>the warning says:</p>

<p>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</p>

<p>The filepermission is 755</p>
