gazalec Posted June 6, 2007 Share Posted June 6, 2007 Hi i was wondering if it was possible for php to search for a file and then display something if it can't find it, for example i have a project where the admin can add a picture through inputting the file name through a form, but i was wondering if there was a way that, if the filename was entered wrong and a file cant be found it shows a different image, such as none.jpg. Thanks For Any Help Quote Link to comment Share on other sites More sharing options...
jscix Posted June 6, 2007 Share Posted June 6, 2007 A file located on the webserver, or are you uploading and displaying a temporary file? Quote Link to comment Share on other sites More sharing options...
jscix Posted June 6, 2007 Share Posted June 6, 2007 if (file_exists($image)) { echo "<i m g s r c = \"fdfdsf.img\">"; } else { echo "< i m g s r c = \"default.img\">"; } basically.. Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 6, 2007 Share Posted June 6, 2007 $image = "images/imagename.jpg"; if (!file_exists($image)) { $image = "images/none.jpg"; } echo "<img src=\"$image\">"; Quote Link to comment Share on other sites More sharing options...
gazalec Posted June 6, 2007 Author Share Posted June 6, 2007 ok thanks alot i wasn't sure if file_exist existed thanks thats fixed it Quote Link to comment Share on other sites More sharing options...
per1os Posted June 6, 2007 Share Posted June 6, 2007 You could always check www.php.net/file_exists Good source to tell if functions exists or not, or to even find certain functions. Quote Link to comment 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.