<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>drew &#187; Uncategorized</title>
	<atom:link href="http://drewjoh.com/blog/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://drewjoh.com/blog</link>
	<description>Words on your display.</description>
	<lastBuildDate>Sat, 16 Jan 2010 07:13:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Serving a large file through PHP without hitting memory_limit</title>
		<link>http://drewjoh.com/blog/2008/09/serving-a-large-file-through-php-without-hitting-memory_limit/</link>
		<comments>http://drewjoh.com/blog/2008/09/serving-a-large-file-through-php-without-hitting-memory_limit/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 05:44:15 +0000</pubDate>
		<dc:creator>Drew</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[WebDev]]></category>
		<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://drewjoh.com/blog/?p=34</guid>
		<description><![CDATA[
			
				
			
		
Ran into a little problem hitting the memory limit for PHP when serving 100MB+ files through a script like:
$file = @fopen($filename,"r");
if ($file)
{
    while(!feof($file))
        {
            print(fread($file, 1024*4));
            flush();
 [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdrewjoh.com%2Fblog%2F2008%2F09%2Fserving-a-large-file-through-php-without-hitting-memory_limit%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fdrewjoh.com%2Fblog%2F2008%2F09%2Fserving-a-large-file-through-php-without-hitting-memory_limit%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Ran into a little problem hitting the memory limit for PHP when serving 100MB+ files through a script like:</p>
<p><code>$file = @fopen($filename,"r");<br/><br />
if ($file)<br />
{<br />
    while(!feof($file))<br />
        {<br />
            print(fread($file, 1024*4));<br />
            flush();<br />
            ob_flush();<br />
        }<br />
    @fclose($file);<br />
}</code></p>
<p>Found that you need to call ob_flush() as well as flush() since flush() has <a href="http://us3.php.net/manual/en/function.flush.php">no effect on the buffering scheme of your web server</a>.</p>
<p>Just thought I&#8217;d throw that out there for anyone else.</p>
]]></content:encoded>
			<wfw:commentRss>http://drewjoh.com/blog/2008/09/serving-a-large-file-through-php-without-hitting-memory_limit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
