yea. all the files aren't 100MB though.. some are 2mb (even less) while some
files are over 300MB as well.
so, does this need to be adjusted depending on the filesize?

thanks.

----- Original Message ----- 
From: "Rory Browne" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: "Sebastian" <[EMAIL PROTECTED]>; <php-general@lists.php.net>
Sent: Friday, December 31, 2004 10:24 PM
Subject: Re: [PHP] handling large files w/readfile


> I'd go with Richards Basic idea, but if you're outputting a 100Mb file
> I'd use a hell of a lot bigger chunks than 4K. With the syscall and
> loop overhead, i'd go with at least half a megabyte, or more likely
> 2Mb depending on your amount of memory.
>
> To do this you'd change Richards
>
> echo fread($fp, 4096); //4K chunks
>
> to
>
> echo fread($fp, 2048000); // ~2Mb chunks (actually 2000KB but couldn't
> be bothered counting, and 2Mb is an arbitory figure anyway)
>
> Just make sure you don't have output buffering on.
>
>
> On Fri, 31 Dec 2004 15:17:51 -0800 (PST), Richard Lynch <[EMAIL PROTECTED]>
wrote:
> > Sebastian wrote:
> > > i'm working on a app which output files with readfile() and some
headers..
> > > i read a comment in the manual that says if your outputting a file php
> > > will
> > > use the same amount of memory as the size of the file. so, if the file
is
> > > 100MB php will use 100MB of memory.. is this true?
> > >
> > > if it is, how can i work around this?
> >
> > I don't know if it's STILL true (or ever was) that readfile() would suck
> > the whole file into RAM before spitting it out...  Seems real unlikely,
> > but...
> >
> > At any rate, you can simply do:
> >
> > $file = 'whatever.mb';
> > $fp = @fopen($file, 'r') or trigger_error("Could not read $file",
> > E_USER_ERROR);
> > while (!feof($fp)){
> >   echo fread($fp, 4096); //4K chunks
> > }
> >
> > http://php.net/fopen http://php.net/fread http://php.net/feof
> >
> > --
> > Like Music?
> > http://l-i-e.com/artists.htm
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

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

Reply via email to