(413) Request Entity Error loading PHP file too big

I am having a problem with loading a PHP file. I am trying to submit a form using AJAX. This ajax request contains text variables and files. When I try to send only one file, everything will be fine, but if I send several files. I get a 413 Request Entity Too Large message . I am using Apache. Here is my code

var data = new FormData();
data.append( 'name','my upload file');

var img1 = $('#src1').find('img').attr('src');
var img2 = $('#src2').find('img').attr('src');
var img3 = $('#src3').find('img').attr('src');
var img4 = $('#src4').find('img').attr('src');
if(img1 != undefined)
{
    data.append( 'image1', img1);    
}
else
{
    data.append( 'image1', "");        
}
if(img2 != undefined)
{
   data.append( 'image2', img2);    
}
else
{
   data.append( 'image2', "");        
}
if(img3 != undefined)
{
   data.append( 'image3', img3);    
}
else
{
   data.append( 'image3', "");        
}
if(img4 != undefined)
{
   data.append( 'image4', img4);    
}
else
{
   data.append( 'image4', "");         
}

$.ajax({
       type: "POST",
       url: "server.php",
       data: data,
       cache: false,
       processData: false,
       contentType: false,
       success: function(result){
         console.log(1);
       }
});

All my downloaded files are less than 700 KB, I also checked the PHP setup with ini_get_all (), and I found that post_max_size is 48 MB, upload_max_filesize is 32 MB. I don’t understand what is the cause of this problem.

, , ( 10 ), ​​ , 400 . .

+1
3

nginx conf (/usr/local/nginx/conf/nginx.conf)

client_max_body_size 512M;//set it to higher mb

nginx

service nginx restart
+2

. http://httpd.apache.org/docs/2.0/mod/core.html#limitrequestbody

httpd.conf .htaccess

LimitRequestBody 0 #Unlimited

Apache, .

httpd/apache, , ModSecurity. , ModSecurity. /etc/modsecurity/modsecurity.conf

https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#SecRequestBodyNoFilesLimit

+1

You need to set upload_max_filesize and post_max_size in your php.ini:

; Maximum size allowed for uploaded files. upload_max_filesize = 64M

; Must be greater than or equal to upload_max_filesize post_max_size = 64M

After changing the php.ini file (s), you need to restart the HTTP server to use the new configuration.

You can also increase the size using .htaccess in php

php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300
0
source

Source: https://habr.com/ru/post/1653330/


All Articles