Re: How do I check if a remote file exists?
| From: | John Kelly | Date: | Wed, 17 Apr 2002 01:45:28 +0000 |
| Subject: | Re: How do I check if a remote file exists? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-93272@lists.php.net to get a copy of this message | ||
"John Kelly" <johnkelly@hotmail.com> wrote in message
news:20020417004325.89527.qmail@pb1.pair.com...
> How do I check if a remote file exists that is in a directory protected by
> an .htaccess file?
>
I should have added that this is the code I have tried without success ...
$url = "www.domain.com";
$file = "/directory/file.php";
$fid = fsockopen($url,80);
fputs($fid,"GET $file HTTP/1.0\r\nHost: $url\r\n\r\n");
$gets = fgets($fid, 1024);
fclose($fid);
if (ereg("HTTP/1.1 200 OK", $gets)) {
echo "file exists";
} else {
echo "file missing";
}
If I remove the .htaccess file it works fine.