Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file_exists() error

Status
Not open for further replies.

gcrighton

Technical User
Feb 23, 2002
9
ES
Hi,

I'm trying to use the file_exists() function to load an image but get repeated errors. Code is as follows:

// Foto //
if (file_exists("/production/img/retratos/".$row['ID'].".jpg")) { ?>
<img src='/production/img/retratos/<?PHP echo $row['ID'] ?>.jpg&quot;' width='80' height='80' border='0'>
<? } else { ?>
<img src='/production/img/retratos/nophoto.jpg' width='80' height='80' border='0'>
<? }

The result of the above code is to set ALL images as non-existent and to load the no photo image (even though the photos do exist). It's not Db related as the standard images call here:

echo (&quot;<img src='/production/img/retratos/&quot;.$row['ID'].&quot;.jpg' width='80' height='80' border='0'>\n&quot;);

... works just fine.

What am I missing? Surely the file does not have to be in the same dir?

Thanks for any advice / comments.

Gary
 
file_exists uses filesystem absolute path instead of http absolute path.
Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Hi Anikin,

Ok as far as I know the absolute file system path on the clients ISP is included below (this is the path used for php includes for example):

// Foto //
if (file_exists(&quot;/u/web/circul/production/img/retratos/&quot;.$row['ID'].&quot;.jpg&quot;)) {
echo (&quot;<img src='/production/img/retratos/&quot;.$row['ID'].&quot;.jpg' width='80' height='80' border='0'>&quot;);
} else {
echo (&quot;<img src='/production/img/retratos/nophoto.jpg' width='80' height='80' border='0'>&quot;);
}

But this still does not work. As is shown above it only chooses the first option. Without the / before the u it only displays the second option!

Gary
 
i don't use this function :( sorry :(

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Check you have read permissions of the files and also on the directory containg the file.
file_exists() returns not found if it does not had the correct read permissions for the file and location. ***************************************
Party on, dudes!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top