php3-list | 199807
Date: 07/31/98
- Next message: johan.gronvall <email protected>: "RE: [PHP3] 2 f* questions"
- Previous message: Brian S. Craigie: "Re: [PHP3] PUT script needed - a way to do it"
- Maybe in reply to: johan.gronvall <email protected>: "[PHP3] 2 f* questions"
- Next in thread: johan.gronvall <email protected>: "RE: [PHP3] 2 f* questions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: johan.gronvall <email protected>: "RE: [PHP3] 2 f* questions"
- Previous message: Brian S. Craigie: "Re: [PHP3] PUT script needed - a way to do it"
- Maybe in reply to: johan.gronvall <email protected>: "[PHP3] 2 f* questions"
- Next in thread: johan.gronvall <email protected>: "RE: [PHP3] 2 f* questions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

