dreamwest Posted February 9, 2009 Share Posted February 9, 2009 Sometimes thumbnail images dont exist due to GD not making one , i need to check if the file exists otherwise display a default image Actual image <img src="http://www.site.com/thumb/7324.jpg" > and if image dosnt exist display this instead of nothing: <img src="http://www.site.com/no_image.jpg" > Quote Link to comment https://forums.phpfreaks.com/topic/144542-solved-check-if-file-exists/ Share on other sites More sharing options...
genericnumber1 Posted February 9, 2009 Share Posted February 9, 2009 http://us2.php.net/file_exists Quote Link to comment https://forums.phpfreaks.com/topic/144542-solved-check-if-file-exists/#findComment-758474 Share on other sites More sharing options...
The Little Guy Posted February 9, 2009 Share Posted February 9, 2009 Like this: $file = '../images/myfile.jpg'; if(file_exists($file)){ echo 'Found File!'; }else{ echo 'No File Found '; } Quote Link to comment https://forums.phpfreaks.com/topic/144542-solved-check-if-file-exists/#findComment-758479 Share on other sites More sharing options...
mat-tastic Posted February 9, 2009 Share Posted February 9, 2009 With your example like this: $file = '/thumb/7324.jpg'; // change as necessary if(file_exists($file)){ // display http://www.site.com/thumb/7324.jpg }else{ // display http://www.site.com/no_image.jpg } Quote Link to comment https://forums.phpfreaks.com/topic/144542-solved-check-if-file-exists/#findComment-758487 Share on other sites More sharing options...
dreamwest Posted February 9, 2009 Author Share Posted February 9, 2009 Sweet! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/144542-solved-check-if-file-exists/#findComment-758517 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.