|
Posted by Eric Layman on 02/02/07 14:17
Thanks!
btw, why is there a need for \r\n\r\n appended to the url?
"Janwillem Borleffs" <jw@jwscripts.com> wrote in message
news:45c1cca6$0$48643$dbd43001@dr2.euro.net...
> Eric Layman schreef:
>> According to the PHP documentation:
>>
>> it stated that as of php5, filesize supports the reading of remote html
>> files:
>>
>> http://php.net/manual/en/function.filesize.php
>>
>
> It also states that you should look in the HTTP wrapper section of the
> appendix to see if it's supported by the stat() function. Like this
> function, filesize() only works on local files and doesn't support the
> HTTP protocol.
>
> If you want to check the size of a remote file, you could do something as
> follows:
>
> $fp = fsockopen('www.google.com', 80);
> fputs($fp, "HEAD / HTTP/1.0\r\n");
> fputs($fp, "Host: www.google.com\r\n\r\n");
>
> $size = 0;
> while (!feof($fp)) {
> $line = fgets($fp, 1024);
> if (preg_match('/content-length:\s*(\d+)/i', $line, $m)) {
> $size = $m[1];
> break;
> }
> }
> fclose($fp);
>
> print "Size of Google homepage HTML: $size bytes";
>
>
> JW
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
[Back to original message]
|