Re: handling large files w/readfile

From: Date: Sun, 26 Dec 2004 23:31:28 +0000
Subject: Re: handling large files w/readfile
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-205188@lists.php.net to get a copy of this message
Hello! > 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? Do not use readfile() or file_get_contents() to read the full file in one step. Read file in smaller chunks to a buffer variable whith fread() and output that immediately in the cycle. And again and again... You can read terrabytes of data and utput them, the amount of memory needed is based on your buffer size. -- ============================================================= Heilig (Cece) Szabolcs - cece@php.net - http://www.phphost.hu =============================================================

« previous php.general (#205188) next »