Re: throttle output streamed from a file?

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

 



Chris wrote:
readfile works by reading in the whole file at once - if you don't want it to do that, you can't use readfile. You don't need anything complicated, or am I misunderstanding the question which is more likely..

$size = 1048576; // 1Meg.

$fp = fopen($big_file1, 'rb');
while(!feof($fp)) {
  $data = fgets($fp, $size);
  echo $data;
}
fclose($fp);

http://www.php.net/manual/en/function.fgets.php
Will 'echo' block until the client has consumed the whole $size amount of data? If not, how fast will your while loop execute? If file_size($big_file1) exceeds 1 TB, does your server end up sucking up all available memory? Or does PHP crash after hitting a memory limit?

Dante

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