Reputation: 528
I'm having some issues with jQuery/PHP file uploading on my AMI Linux running on EC2 instance.
I tried using this and a couple other plugins (just to ensure the problem wasnt with the plugin itself), with the same results.
When trying to upload a 14MB PDF the progress bar reaches 75% (or more, up to 99%), then it restarts from 0%, it reaches again 75% (or more, up to 99%) and then it just stops with no error (not even saying Request Timeout
).
Doing several attempts, only a couple of times the progress bar reached 99% without restarting, and then error popped up saying Request Timeout
.
This is what i found in apache's access_log
:
12.34.56.78 - - [02/Jul/2019:15:50:09 +0000] "POST /uploader/demo/backend/upload.php HTTP/1.1" 408 221
12.34.56.78 - - [02/Jul/2019:15:50:31 +0000] "POST /uploader/demo/backend/upload.php HTTP/1.1" 408 221
So it prints 408 Request Timeout
on 2 lines (infact the upload restarts once). The upload takes 22 or 23 seconds (as can be seen in the logs).
This is how i set my php.ini
(i'm using PHP 7.1 FPM):
max_execution_time = 360
max_input_time = 360
memory_limit = 256M
post_max_size = 100M
upload_max_filesize = 100M
phpinfo()
shows that those values are properly applied.
I also tried to use set_time_limit(0)
and set all above values in the upload.php
file with ini_set()
, but nothing changed.
Upload directory has proper permissions, infact an 9.3MB PDF is uploaded correctly with no errors.
In one of my attempts i tried also to set these apache directives:
KeepAlive On
KeepAliveTimeout 360
TimeOut 360
With the only result that the upload progress kept reaching 99% and restarting several times instead than restating only once.
Now i run out of ideas and most solutions proposed are related to php.ini
settings which in my case are properly applied.
Upvotes: 0
Views: 238
Reputation: 528
After hours of attempts, as soon as i posted my question, i found the answer. It might be useful to anyone having the same issue. If everything else listed in my question doesnt work, it might be due to mod_reqtimeout (as it was for me).
I simply created a file named: /etc/httpd/conf.d/mod_reqtimeout.conf
and put this inside of it:
<IfModule reqtimeout_module>
RequestReadTimeout header=20-40,MinRate=500 body=20,MinRate=500
</IfModule>
as suggested by the apache doc linked above. Then i restarted apache and the upload reached 100% with no problems.
Also mod_security
has taken part in this when i tried with a 60MB PDF. I had to set the following setting to match the 100MB limit that was set in php.ini
, inside /etc/httpd/conf.d/mod_security.conf
:
SecRequestBodyLimit 100000000
Upvotes: 1