slipperyfish Posted July 5, 2006 Share Posted July 5, 2006 I have a fairly simple scirpt to check if an image exists, then give back some feedback:[code]<?phpprint '<br />';print '<center>';$thesrc = $_GET['src'];If (file_exists($thesrc)) { print '<font face="Tahoma" size="2">Valid image source</font>'; print '<br /><br />'; print '<img src="' .$thesrc. '" />';} else { print '<br />'; print '<center>'; print '<font face="Tahoma" size="2">Invalid image source</font>';}print '</center>';?>[/code].. but this just always reutnrs false... and suggestions :S ?? Quote Link to comment https://forums.phpfreaks.com/topic/13692-file-exists-not-working/ Share on other sites More sharing options...
trq Posted July 5, 2006 Share Posted July 5, 2006 [code=php:0]if (file_exists(trim($thesrc))) {[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13692-file-exists-not-working/#findComment-53139 Share on other sites More sharing options...
slipperyfish Posted July 5, 2006 Author Share Posted July 5, 2006 Unfortunately, adding the trim function didn't work. it will says: "Invalid Image Source".Anybody any more ideas why it's does that? Quote Link to comment https://forums.phpfreaks.com/topic/13692-file-exists-not-working/#findComment-53231 Share on other sites More sharing options...
slipperyfish Posted July 5, 2006 Author Share Posted July 5, 2006 ___Sorry, just trying to get this seen___ Quote Link to comment https://forums.phpfreaks.com/topic/13692-file-exists-not-working/#findComment-53241 Share on other sites More sharing options...
mrwhale Posted July 5, 2006 Share Posted July 5, 2006 file_exists only works within your own site and cannot include http://blah.comso use this instead[code]<?phpprint '<br />';print '<center>';$thesrc = $_GET['src'];if( parse_url( $thesrc ) ){ print '<font face="Tahoma" size="2">Valid image source</font>'; print '<br /><br />'; print '<img src="' .$thesrc. '" />';}else{ print '<br />'; print '<center>'; print '<font face="Tahoma" size="2">Invalid image source</font>';}print '</center>';?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13692-file-exists-not-working/#findComment-53244 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.