Hi all - I'm trying to find a foolproof method for determining whether a file exists on a remote system.
Let's say I'm on myurl.com, and I need to determine whether file xyz.txt exists on otherurl.com
I get some really wacky results from PHP when I use any of the standard file functions, like fopen or file_exists
or any of the other "wrapper" functions. For example, fopen and fread let me read non-existent files! (feof doesn't
seem to work with remote files).
file_exists return FALSE whether or not the file exists on the remote system.... let's see, this is PHP 5 running
on Apache without safe mode and with all the usual accoutrements in place.
Does anyone know of a good way to accomplish this? It's really simple, I don't need the file contents or anything,
I just need a reliable "yes or no" answer for "does the file exist in the location I've specified".
Thanks - your help is greatly appreciated!
remote file question
Moderator: General Moderators
Re: remote file question
just throwing it out there...
Could maybe use ftp_size to validate the file is there by returning the value of the request or its error...
Could maybe use ftp_size to validate the file is there by returning the value of the request or its error...
Re: remote file question
There is no foolproof way to check if a file exists over HTTP.
As Architek suggested you can try another protocol, such as FTP.
As Architek suggested you can try another protocol, such as FTP.