function file_exists not working in php

Posted by Rakesh R Nair on Stack Overflow See other posts from Stack Overflow or by Rakesh R Nair
Published on 2012-07-09T09:12:17Z Indexed on 2012/07/09 9:15 UTC
Read the original article Hit count: 161

Filed under:
|

I have been trying to find if a file_exist in the directory. If not i want to use a different image. But as i am using the file_exists function it always returns false.

The code i used is

    while($r=mysql_fetch_row($res))
            {  
                                    if(!file_exists('http://localhost/dropbox/lib/admin/'.$r[5]))
                    {
                        $file='http://localhost/dropbox/lib/admin/images/noimage.gif';
                    }
                        else
                            $file='http://localhost/dropbox/lib/admin/'.$r[5];}

But the function always return false even if the file exits. I checked that by using

<img src="<?php echo 'http://localhost/dropbox/lib/admin/'.$r[5]; ?>" />

This displayed the image correctly.

Please Someone Help Me

© Stack Overflow or respective owner

Related posts about php

Related posts about html