tomtom Posted August 20, 2008 Share Posted August 20, 2008 Hey. How can you check an external file exists? I'm trying if(file_get_contents("http://myfile.com/test.ini")) { // do my code if the file exists } right. But I just get Warning: file_get_contents(http://myfile.com/test.ini) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in... etc. Any suggestions? I want it to return true if the file exists; but if it doesn't exist - I don't want it to return that error - or any error lol. Cheers guys (y) Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted August 20, 2008 Share Posted August 20, 2008 file_exists() surprisingly enough http://us.php.net/file_exists Quote Link to comment Share on other sites More sharing options...
tomtom Posted August 20, 2008 Author Share Posted August 20, 2008 Yeah I've tried that - but it doesn't work on external files Well it doesn't on my server anyway. Running PHP version: 5.2.6 Quote Link to comment Share on other sites More sharing options...
tomtom Posted August 20, 2008 Author Share Posted August 20, 2008 OH. file_exists does work. I must have done something different :S Cheers man Quote Link to comment Share on other sites More sharing options...
tomtom Posted August 21, 2008 Author Share Posted August 21, 2008 Oh wait...It doesn't work haha. It always returns false. Even if the file does exist. No error. Just always returns false. Quote Link to comment Share on other sites More sharing options...
trq Posted August 21, 2008 Share Posted August 21, 2008 Check your phpinfo() to make sure you have url wrappers enabled. Quote Link to comment Share on other sites More sharing options...
tomtom Posted August 21, 2008 Author Share Posted August 21, 2008 Ahh don't worry. I've settled with @file_get_contents($file) Hides the errors and works ty anyway! 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.