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 } ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.