You are here: Re: filesize() not reading http pages « All PHP « IT news, forums, messages
Re: filesize() not reading http pages

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация