PHP file_exists()无法正常工作[关闭]

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

It's most likely a relative path issue. You may want to try a more absolute path:

<?php $filename = $_SERVER['DOCUMENT_ROOT'].'/my_site/uploads/';?>

Where obviously you provide the path from the document root correctly. If you're not sure what that is, just var_dump($_SERVER['DOCUMENT_ROOT']); and compare that to the path you believe or verify for uploads.