The Little Guy Posted September 21, 2009 Share Posted September 21, 2009 What would be the best way to check if a file exists on another server? Quote Link to comment https://forums.phpfreaks.com/topic/175046-solved-file-exists-on-another-server/ Share on other sites More sharing options...
MadTechie Posted September 21, 2009 Share Posted September 21, 2009 What would be the best way to check if a file exists on another server? 1.go to the server and check 2.Login on to that server and check 3.ask someone near the server to check 4. http://www.phpfreaks.com/forums/index.php/topic,257619.msg1212590.html#msg1212590 Quote Link to comment https://forums.phpfreaks.com/topic/175046-solved-file-exists-on-another-server/#findComment-922564 Share on other sites More sharing options...
The Little Guy Posted September 21, 2009 Author Share Posted September 21, 2009 I figured it out: if(@fopen($todb,"r")){ // file exists }else{ // file doesn't exist } Quote Link to comment https://forums.phpfreaks.com/topic/175046-solved-file-exists-on-another-server/#findComment-922594 Share on other sites More sharing options...
MadTechie Posted September 21, 2009 Share Posted September 21, 2009 Clicking solved helps as a note your need allow_url_fopen enabled for that to work! Quote Link to comment https://forums.phpfreaks.com/topic/175046-solved-file-exists-on-another-server/#findComment-922600 Share on other sites More sharing options...
trq Posted September 21, 2009 Share Posted September 21, 2009 file_existswill work also providing allow_url_fopen is enabled. Quote Link to comment https://forums.phpfreaks.com/topic/175046-solved-file-exists-on-another-server/#findComment-922605 Share on other sites More sharing options...
The Little Guy Posted September 21, 2009 Author Share Posted September 21, 2009 How come, if I try to do an fopen on this: http://www.dmoz.org/Health/Fitness/ I get this: Warning: fopen(http://www.dmoz.org/Health/Fitness/): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\php_files\curl\mp3.php on line 51 But when I open the URL in my browser it works? Quote Link to comment https://forums.phpfreaks.com/topic/175046-solved-file-exists-on-another-server/#findComment-922610 Share on other sites More sharing options...
The Little Guy Posted September 21, 2009 Author Share Posted September 21, 2009 file_existswill work also providing allow_url_fopen is enabled. If I do a file_exists, I get false... I also have this at the top of my php file: ini_set(allow_url_fopen, TRUE); Quote Link to comment https://forums.phpfreaks.com/topic/175046-solved-file-exists-on-another-server/#findComment-922612 Share on other sites More sharing options...
MadTechie Posted September 21, 2009 Share Posted September 21, 2009 Have you tried all the suggestions ? i know at least 1 of them will work Quote Link to comment https://forums.phpfreaks.com/topic/175046-solved-file-exists-on-another-server/#findComment-922614 Share on other sites More sharing options...
The Little Guy Posted September 21, 2009 Author Share Posted September 21, 2009 Yes I tried them all I am using php as "Other CGI" so I can run it from the command line... allow_url_fopen => On => On if I do: ini_get('allow_url_fopen'); It displays "1" but still doesn't work... Quote Link to comment https://forums.phpfreaks.com/topic/175046-solved-file-exists-on-another-server/#findComment-922616 Share on other sites More sharing options...
MadTechie Posted September 21, 2009 Share Posted September 21, 2009 Well that's a shame because it works here with that URL. Quote Link to comment https://forums.phpfreaks.com/topic/175046-solved-file-exists-on-another-server/#findComment-922618 Share on other sites More sharing options...
The Little Guy Posted September 21, 2009 Author Share Posted September 21, 2009 Got it! it was because I was parsing a URL that had a new line at the end of it! Quote Link to comment https://forums.phpfreaks.com/topic/175046-solved-file-exists-on-another-server/#findComment-922620 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.