413 Request Entity Too Large - File Upload Issue

2020-01-27 12:57发布

I am trying to upload 30MB file on my server and its not working.

  1. When I upload 30MB file, the page loads "Page Not Found"

  2. When I upload a 3MB file, I receive "413 Request Entity Too Large" with nginx/0.6.32

I am trying to find nginx so I can increase "client_max_body_size" but I am unable to find nginx installed on my server. I even tried running:

vi /etc/nginx/nginx.conf

or

vi /usr/local/nginx/conf/nginx.conf

to check if the config file exists, but I couldnt find it on my server.

Is there anyway to resolve this issue? Or do I have to installed nginx on my server.

EDIT:

I have made all necessary changes in my php.ini files,

post_max_size 128M
upload_max_filesize 100M
memory_limit 256M

Thanks, Raju

9条回答
神经病院院长
2楼-- · 2020-01-27 13:06

Assuming that you made the necessary changes in your php.ini files:

You can resolve the issue by adding the following line in your nginx.conf file found in the following path:

/etc/nginx/nginx.conf

then edit the file using vim text editor as follows:

vi /etc/nginx/nginx.conf

and add client_max_body_size with a large enough value, for example:

client_max_body_size 20MB;

After that make sure you save using :xi or :wq

And then restart your nginx.

That's it.

Worked for me, hope this helps.

查看更多
Bombasti
3楼-- · 2020-01-27 13:18

Open file/etc/nginx/nginx.conf Add or change client_max_body_size 0;

查看更多
再贱就再见
4楼-- · 2020-01-27 13:21

-in php.ini (inside /etc/php.ini)

 max_input_time = 24000
 max_execution_time = 24000
 upload_max_filesize = 12000M
 post_max_size = 24000M
 memory_limit = 12000M

-in nginx.conf(inside /opt/nginx/conf)

client_max_body_size 24000M

Its working for my case

查看更多
小情绪 Triste *
5楼-- · 2020-01-27 13:22

Use:

php -i

command or add:

phpinfo();

to get the location of configuration file.

Update these variables according to your need and server

max_input_time = 24000
max_execution_time = 24000
upload_max_filesize = 12000M
post_max_size = 24000M
memory_limit = 12000M

On Linux you will need to restart nginx / apache and phpfpm service so the new ini settings are loaded. On xampp, ammps you can restart these from control panel that comes with such applications.

查看更多
再贱就再见
6楼-- · 2020-01-27 13:23

Source: http://www.cyberciti.biz/faq/linux-unix-bsd-nginx-413-request-entity-too-large/

Edit the conf file of nginx:

nano /etc/nginx/nginx.conf

Add a line in the http section:

http {
    client_max_body_size 100M;
}

Doen't use MB it will not work, only the M!

Also do not forget to restart nginx

systemctl restart nginx
查看更多
戒情不戒烟
7楼-- · 2020-01-27 13:23

I add the changes directly to my virtualhost instead the global config of nginx, like this:

   server {
     client_max_body_size 100M;
     ...
   }

And then I change the params in php.ini, like the comments above:

   max_input_time = 24000
   max_execution_time = 24000
   upload_max_filesize = 12000M
   post_max_size = 24000M
   memory_limit = 12000M

and what you can not forget is to restart nginx and php-fpm, in centos 7 is like this:

  systemctl restart nginx
  systemctl restart php-fpm
查看更多
登录 后发表回答