I built a file upload form using AJAX code that runs perfectly on my localhost (xampp/apache). I can upload files as large as 256MB. Using HTTP.
However, when I upload this code to my nginx server on aws ec2 I get a 404 when trying to upload any file larger the 10KB (yes that is a K). I'm using HTTPS.
I thought that maybe the php.ini settings were incorrect so I added this code to the file upload form.
<script> console.log("max_execution_time = <?php echo(ini_get('max_execution_time')); ?>"); console.log("max_input_time = <?php echo ini_get('max_input_time'); ?>"); console.log("memory_limit = <?php echo ini_get('memory_limit'); ?>"); console.log("post_max_size = <?php echo ini_get('post_max_size'); ?>"); console.log("file_uploads = <?php echo ini_get('file_uploads'); ?>"); console.log("upload_max_filesize = <?php echo ini_get('upload_max_filesize'); ?>"); console.log("max_file_uploads = <?php echo ini_get('max_file_uploads'); ?>"); console.log("default_socket_timeout = <?php echo ini_get('default_socket_timeout'); ?>"); </script>
I get this console output.
Note the 0 followed by "File upload success". Here 0 is the file error code i.e.
The two files I uploaded in this case were 9KB.
When you see the
Post ... 404 () at the bottom that was due to me trying to upload a 22KB file.
In nginx.conf I set
Setting size to 0 disables checking of client request body size per the docs http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size
- Wordpress 4.7
- PHP 7.0
- NGINX 1.10