I have an app. that lets you upload multiple files at once through ajax. It’s meant for big files, but once it gets to 2gb+ I reach errors like this:
[Fri Feb 01 11:22:56 2013] [error] [client x.x.x.x] PHP Fatal error: Out of memory (allocated 2331770880) (tried to allocate 1165449891 bytes) in Unknown on line 0, referer: ...
In my php.ini, I have these configs:
post_max_size = 53687091200M
upload_max_filesize = 53687091200M
max_input_time = -1
memory_limit = -1
max_execution_time -1
max_file_uploads = 20
As far as I know, this should be sufficient enough to handle 3GB uploads. But on almost every try, I get those errors. I’ve talked to support for my VPS and they said that all looks good and should be able to handle it.
I’ve got an nginx reverse proxy setup which helped a little bit, but not enough. Am I missing something?
Is there a way to take the load off of HTTP with PHP? I tested Java apps and they performed wonderfully, but (unfortunately) I need to keep the UI in-tact.
If you’re uploading very large files, you might want to “proxy” them before passing them to PHP. My experience is that long-lived PHP threads can bomb out unexpectedly, and that PHP can sometimes have trouble with large memory allocation.
Take a look at nginx’s upload progress module, which will buffer the file to disk before passing it to the upstream server (PHP, in this case) with the added benefit of providing a mechanism for monitoring and reporting on progress.
If you’re still having problems, you can take PHP out of the equasion completely (as far as managing the upload is concerned) by using the upload module; just dump the file directly to the location you need it on disk and notify PHP of it’s whereabouts.