baconbeastnz Posted June 18, 2009 Share Posted June 18, 2009 Hi there I have cod which goes if(file_exist($file)) { } else { echo "<img src=\"$file\"> } And it is running the else command and displaying the file? what is up with that... $file = "subdir/image.jpg"; Quote Link to comment https://forums.phpfreaks.com/topic/162805-file_exists-help/ Share on other sites More sharing options...
flyhoney Posted June 18, 2009 Share Posted June 18, 2009 I imagine that the web path to your file is different than the file system path. What is the absolute path to the file and what is the path to your web directory? Quote Link to comment https://forums.phpfreaks.com/topic/162805-file_exists-help/#findComment-859096 Share on other sites More sharing options...
Hybride Posted June 18, 2009 Share Posted June 18, 2009 Actually, I do believe it's file_exists, not file_exist. Your code says file_exist. Quote Link to comment https://forums.phpfreaks.com/topic/162805-file_exists-help/#findComment-859102 Share on other sites More sharing options...
ldougherty Posted June 18, 2009 Share Posted June 18, 2009 Indeed; should be file_exists http://us3.php.net/file_exists buy even beyond that the logic doesn't add up. (file_exist($file)) { } else { echo "<img src=\"$file\"> } You are essentially saying if the file exists do nothing, if the file does not exist then show the image which is the file which apparently doesn't exist? Quote Link to comment https://forums.phpfreaks.com/topic/162805-file_exists-help/#findComment-859181 Share on other sites More sharing options...
baconbeastnz Posted June 20, 2009 Author Share Posted June 20, 2009 I am actually using file_exists sorry about that: the code is: if(file_exists("$pictureAlbumsRoot/$name/thumbs/$value")) { //Note the file_exists must echo '<div id="albumDetailsNode" style="float:left;">'; echo "<img src=\"$pictureAlbumsRoot/$name/thumbs/$value\"> "; echo '</div>'; } else { echo 'fail'; } if i get rid of the if, the picture displays fine, but with the if, else fires. Is tehre anyway to figure out what file_exists considers my root directory to be? Quote Link to comment https://forums.phpfreaks.com/topic/162805-file_exists-help/#findComment-860214 Share on other sites More sharing options...
wildteen88 Posted June 20, 2009 Share Posted June 20, 2009 You need debug your file path. What is returned when you echo out your file path? echo $pictureAlbumsRoot.'/'.$name.'/thumbs/'.$value; Quote Link to comment https://forums.phpfreaks.com/topic/162805-file_exists-help/#findComment-860225 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.