[Reminder] Disable output-buffering when sending a download to the browser

Posted by Eric Bartels

If you want to “send a file” to the browser (even if you do it in chunks) and your output-buffering is on you will get a fatal error when having large files.

Fatal error: Allowed memory size of 0815 bytes exhausted

It makes sense. The data of the file gets buffered. And after a while the buffer is full.

Always disable your output-buffering before you start sending chunks of data (which represent a file download).

ob_end_clean ();

Leave a Reply