Jump to content

If file exists show image uploaded else show no image file


admin2gd1

Recommended Posts

Here is something quick someone can help me with. I can't get the second image to show.

 

If the photo in the database and directory doesn't exist then show image 2 but it's not doing it because it is still trying to read from the directory where the photos would be, so it ignores the second image in less that directory does not exist also.

 

Now the thing is I have 12 photos all together in one directory and the directory needs to exist for the other 11 photos so what I want is the second image to show and not try to read from the directory.

 

This is my code that I am using, don't worry about $SITEurl and $username and $name they are working.

 

<?php if(file_exists("../photos/properties/$username/$name/$photo1")){ ?>
<img class="photo" src="<?php echo $SITEurl ?>/photos/properties/<?php echo $username; ?>/<?php echo $name; ?>/<?php echo $photo1; ?>" alt="">
<?php }else{ ?><img class="photo" src="<?php echo $SITEurl; ?>/images/<?php echo getLang(noimage); ?>" alt=""><?php } ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.