Fix unresponsive browser when serving files via PHP

After an hour long reading his frustrations over IM, I began google’ing on files served thru PHP but locks clicks in a client’s browser until download is finished. It is unresponsive until the download is complete.

// add this function before a readfile() or chunked with fopen()
session_write_close();
// header goes here, content-type, filename, etc
readfile($filepath);

And, also, I found this class to support downloading using a download manager.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">