I have read some of the answered question here at stackoverflow which is quiet related to my problem but still I can't figure out what's wrong with my code. It does not check if the file already exist it only returns the default image even there is an existing file in my uploads folder. This is my first time to use file_exists() I'm not really familiar with this code.
here is my code:
<?php $filename = 'uploads/';?>
<?php if(file_exists($filename)) {?>
<img src='<?php echo base_url();?>uploads/' width='180' height='200' id="images"name='images' />
<?php } else { ?>
<img src='<?php echo base_url();?>assets/images/no_image.jpg' width='180' height='200' id="images" name='images' />
<?php } ?>
Thanks for any help..