CodeIgniter Forums
Check if Image exists in folder - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Check if Image exists in folder (/showthread.php?tid=1985)



Check if Image exists in folder - El Forum - 07-10-2007

[eluser]woracal[/eluser]
I need to display several images in a page. Some thumbnails images may not exist so I need to display an alternate image instead. Basically, i need to check if an image exists and display an alternative if it does not. Any comments would help.


Check if Image exists in folder - El Forum - 07-10-2007

[eluser]Glen Swinfield[/eluser]
Code:
if(!file_exists($file)){
   // display alternative
}else{
   // display file
}

Hope this helps - there may be a CI alternative - but what's the point when there's a native php function.


Check if Image exists in folder - El Forum - 07-10-2007

[eluser]woracal[/eluser]
Thanks! Duh... that was easier than I thought. Spent my time looking for CI functions! So s.tupid! Smile