I am using the file uploader plugin (from: https://github.com/valums/file-uploader) to upload files to my website.
If you are using a moden web browser (like Firefox 6 or Chrome 13), then it uploads by streaming the file in the POST body, and can give you a progress bar. If you're using IE (or an old browser), it falls back on the standard $_FILES (using a hidden iFrame).
Everything was working fine, but suddenly I can't upload 5MB files in Chrome or Firefox. When I upload a 5MB file in Chome or Firefox I get a 500 error and my PHP code is never even ran. If I use Internet Explorer (which uses $_FILES), it works fine.
This has to be a configuration problem, as my PHP code never even runs. So, I checked my settings.
/etc/php.ini
upload_max_filesize = 15M
post_max_size = 16M
I looked for LimitRequestBody
, but that's nowhere to be found (and the default is unlimited).
Settings look right. I debugged this for a while, and I can not figure out what is wrong.
Is there a setting I'm missing? The server has suhosin installed, if that matters.
I know my PHP code works, as files less than 4MB upload fine (on all browsers). I only have a problem with files bigger than 5MB (using Chrome/Firefox). The weird thing is, this works fine on my test server, but not my production server. They probably have different settings (suhosin is on production, but not on test).
I think the problem is here and specifically in the stream_copy_to_stream () which seems to be a memory hog because (and I only assume) it copies the whole(?) file to be uploaded to memory. So check suhosin.memory_limit and memory_limit in php.ini
PS I don't know the etiquette here if I should submit it as an answer or a comment, but I'll leave it as an answer for the time.