Re: throttle output streamed from a file?
| From: | D. Dante Lorenso | Date: | Wed, 10 May 2006 04:11:23 +0000 |
| Subject: | Re: throttle output streamed from a file? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-235842@lists.php.net to get a copy of this message | ||
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