Hello
Jul 9 2005, 02:27 AM
Hello,
I am trying to efficiently detect if file exist at the specific URL where
URL points to a completely different web server than where the script is
being run at. I need constatnly check for a log file on another server and I
need my script to detect that file there exists when the script checks for
it. Right now I have the only way to see if file exists only by downloading
the whole file with the following piece of code:
ob_start();
$file = @readfile($url);
$contents = ob_get_contents();
ob_end_clean();
and see if read was empty or not. Problem is that if the log will happen to
be a few megs then the alarm will be delayes since it will take a few mins
to download the whole file first. Is there a more efficient way to check for
existence of the file on the remote webserver without downloading the file
and checking for the length?
I'd take any idea you might have. Thanks.
nemo
Jul 9 2005, 06:55 AM
On Sat, 09 Jul 2005 03:27:21 GMT, "Hello" <[Email Removed]> wrote:
QUOTE |
Hello,
I am trying to efficiently detect if file exist at the specific URL where URL points to a completely different web server than where the script is being run at. I need constatnly check for a log file on another server and I need my script to detect that file there exists when the script checks for it. Right now I have the only way to see if file exists only by downloading the whole file with the following piece of code:
ob_start(); $file = @readfile($url); $contents = ob_get_contents(); ob_end_clean();
and see if read was empty or not. Problem is that if the log will happen to be a few megs then the alarm will be delayes since it will take a few mins to download the whole file first. Is there a more efficient way to check for existence of the file on the remote webserver without downloading the file and checking for the length?
I'd take any idea you might have. Thanks.
Does |
Hello
Jul 9 2005, 08:05 AM
No, that function can only be applied to a same server where the script is
being run off, it will not do anything to a remote server.
After thinking a bit, I came up with this code (some parts were removed for
clarity):
$handle = @fopen($url, 'r');
if ($handle===false) { //not on server }
else fclose($handle); //on server
If anyone has any ideas or other ways, I am all ears.
Thanks.
"nemo" <nemo@not_hotmail.com> wrote in message
news:[Email Removed]...
QUOTE |
On Sat, 09 Jul 2005 03:27:21 GMT, "Hello" <[Email Removed]> wrote:
Hello,
I am trying to efficiently detect if file exist at the specific URL where URL points to a completely different web server than where the script is being run at. I need constatnly check for a log file on another server and I need my script to detect that file there exists when the script checks for it. Right now I have the only way to see if file exists only by downloading the whole file with the following piece of code:
ob_start(); $file = @readfile($url); $contents = ob_get_contents(); ob_end_clean();
and see if read was empty or not. Problem is that if the log will happen to be a few megs then the alarm will be delayes since it will take a few mins to download the whole file first. Is there a more efficient way to check for existence of the file on the remote webserver without downloading the file and checking for the length?
I'd take any idea you might have. Thanks.
Does http://uk2.php.net/manual/en/function.file-exists.php help? |
Colin McKinnon
Jul 11 2005, 08:01 AM
Hello wrote:
HTTP provides for this (HEAD). IIRC this is not directly accessible via the
the file wrappers. It is possible via the command line version of curl - so
I'm guessing it's possible with libcurl too.
HTH
C.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.