Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 199807

RE: [PHP3] 2 f* questions From: johan.gronvall <email protected>
Date: 07/31/98

Hmm, it looks like I forgot to CC: the list. Rasmus was kind enough to
tell me about the fread function. I wasn't aware of its existens. Well,
well, I try your code and get back to you if I can't get it to work.
Thank you!

/Johan

--------------------------------------
Johan Grönvall
BTJ AB
S-221 82 LUND
work: +46 46 180343
cellular: +46 0708 627588
fax: +46 46 306219
---------------------------------------------------

>----------
>From: Brian Schaffner[SMTP:BSchaffner <email protected>]
>Sent: den 31 juli 1998 16:26
>To: Grönvall Johan; php3 <email protected>
>Subject: RE: [PHP3] 2 f* questions
>
>This may not be exactly what you're looking for - but it could be
>modified fairly
>easily. it uses HTTP headers to find the file size (content-length) and
>then does an fread (not fgetc!). should work for any file transmitted
>via HTTP.
>
>Brian Schaffner, Manager of Internet Services
>ACCENT Marketing Services, Inc.
>
>
><?
> $gotheaders = False;
> $headerlen = 0;
> $fp = fsockopen("localhost", 80);
> if ($fp > 0) {
> fputs($fp, "GET /index.html HTTP/1.0\n\n");
> while (!feof($fp) && !$gotheaders) {
> $buf = fgets($fp, 1024);
> $headerlen += strlen($buf);
> if (strstr(strtolower($buf), "content-length"))
>{
> $clen = $buf;
> }
> if (strstr(strtolower($buf), "content-type")) {
> $gotheaders = True;
> $buf = fgets($fp, 1024);
> $headerlen += strlen($buf);
> $buf = fgets($fp, 1024);
> $headerlen += strlen($buf);
> }
> }
>
> if ($gotheaders) {
> $foo = strtok($clen, ":");
> $n = strtok(":");
> trim(&$n);
> $len = Intval($n);
> $data = fread($fp, $len);
> }
> fclose($fp);
> }
>
> echo $data;
>?>
>
>> -----Original Message-----
>> From: johan.gronvall <email protected> [mailto:johan.gronvall <email protected>]
>> Sent: Friday, July 31, 1998 9:11 AM
>> To: php3 <email protected>
>> Subject: [PHP3] 2 f* questions
>>
>>
>> Hi all,
>>
>> 1. The use of fgetc (http) is not very fast if I want to
>> download a big
>> gif for example(or any _binary_ file), instead it would have been nice
>> to redirect fpassthru to a file. Is that possible or is there
>> any other
>> solution?
>>
>> 2. Can I somehow tell the size of the file being downloaded.
>>
>> Thanks,
>>
>> Johan
>> --------------------------------------
>> Johan Grönvall
>> BTJ AB
>> S-221 82 LUND
>> work: +46 46 180343
>> cellular: +46 0708 627588
>> fax: +46 46 306219
>> ---------------------------------------------------
>>
>> --
>> PHP 3 Mailing List http://www.php.net/
>> To unsubscribe send an empty message to php3-unsubscribe <email protected>
>> To subscribe to the digest list: php3-digest-subscribe <email protected>
>> For help: php3-help <email protected> Archive:
>> http://www.php.net/mailsearch.php3
>>
>>
>
>--
>PHP 3 Mailing List http://www.php.net/
>To unsubscribe send an empty message to php3-unsubscribe <email protected>
>To subscribe to the digest list: php3-digest-subscribe <email protected>
>For help: php3-help <email protected> Archive:
>http://www.php.net/mailsearch.php3
>
>

--
PHP 3 Mailing List   http://www.php.net/
To unsubscribe send an empty message to php3-unsubscribe <email protected>
To subscribe to the digest list:  php3-digest-subscribe <email protected>
For help: php3-help <email protected>  Archive:  http://www.php.net/mailsearch.php3