Re: How to count transfered kBytes in File-Download

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>     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.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux