Re: How to count transfered kBytes in File-Download
| From: | ceo at l-i-e dot com | Date: | Mon, 05 Jan 2009 15:27:52 +0000 |
| Subject: | Re: How to count transfered kBytes in File-Download | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-285465@lists.php.net to get a copy of this message | ||
> echo fread($HANDLER, $FSIZE);
This is your problem child right here...
Sucking in an entire OGG File to RAM, for a large OGG file, will be quite painful.
And, on a busy server, even moderate size files will be problematic.
You could probably relieve a lot of stress and keep full-size downloads just by doing:
define('CHUNK_SIZE', 2048);
define('DOWNLOAD_LIMIT', 10*1024);
while (!feof($HANDLER)){
echo fread($HANDLER, CHUNK_SIZE);
}
To answer your original question, you would abort this loop partway though, using some kind of
counter *= CHUNK_SIZE and compare it to DOWNLOAD_LIMIT.