|
Posted by Arkady Renko on 10/05/06 08:18
howachen@gmail.com wrote:
> > howachen@gmail.com 寫道:
> >
>> >> I have many text file with 1 to 2MB in size
>> >>
>> >> currently, i use the method:
>> >>
>> >> echo file_get_contents( $file_path );
>> >>
>> >>
>> >> are there any better method?
>> >>
>> >> thanks.
> >
> > gzip take time, if many people access the page, my server will be
> > killed....
> >
> > what i want to look for is if any method can send the file to apache
> > for display with getting back the content to the php first, i.e. i want
> > streaming, no matter the size of the file, even 1GB
> >
> > echo file_get_contents( $file_path ); // no good, as content will be
> > passed back in the STACK during function call
> >
> > // i want sth like...streaming
> > print_file_to_client( $file_path );
> >
If you want to stream the file (without compressing it) then why not use
fread to read small "chunks" of the file?
Something like this...
$chunk = (8024);
$buffer = '';
$handle = fopen($filename, 'rb');
if ($handle === false) die();
while (!feof($handle))
{
$buffer = fread($handle, $chunk);
print $buffer;
flush();
ob_flush();
}
fclose ($handle);
-- -------------------- Arkady Renko Network Admin To email me directly
Remove all capitals and underscores from my posting address
[Back to original message]
|