How can I display an image w/ php only if it exists? I tried the file_exist function, but I do it sensed that the file existed everytime. the images are uploaded via a user, and the image is placed in a folder called propertyimages and the image name is placed in a table called image1 inside of a database. then when it comes time for them to be displayed, I am connecting to the database and using the following script to show the image:
<? echo '<img src="propertyimages/'.$row_Rs['imageone'].'" height="200" width="200" vspace="10" hspace="10" >'; ?>
now how can I alter this so that it will only show if it actually exists? this is the file_exist function I used:
$filename = 'propertyimages/'.$_row_Rs['imageone'];
if (file_exists($filename)) { echo '<img src="propertyimages/'.$row_Rs['imageone'].'" height="200" width="200" vspace="10" hspace="10" >'; }
else {
echo " ";
}