I saw a lot of questions about how to use PHP effectively for file uploads, and not for direct HTTP requests (to protect files, track downloads, etc.).
The answer is almost always PHP readfile () .
- Upload large files in PHP
- How to force downloading large files without using too much memory?
- Best way to transparently download logs?
BUT, although it works great during testing with huge files, when it is on a live site with hundreds of users, downloads start to freeze and PHP's memory limits are exhausted.
So, how does readfile() , which causes the memory to explode so much when the traffic is high? I thought it should get around the heavy PHP memory usage by writing directly to the output buffer?
EDIT: (To clarify, I'm looking for βwhy,β not βwhat can I do.β I think Apache mod_xsendfile is the best way around)
php memory readfile
tmsimont Jul 08 '11 at 17:12 2011-07-08 17:12
source share