Using php to upload a picture (size 1.9M), nginx: 413 Request Entity Too Large error occurs. According to experience, the server limits the size of the uploaded file, but the default file upload of php is 2M, so there should be no problem.
Open php.ini, change upload_max_filesize
and post_max_size
to 20M
, then restart.
Upload again, the problem is still the same, you can rule out the problem of php.
It turns out that the default upload file size of nginx is 1M, which can be modified in the settings of nginx.
The workaround is as follows:
Open the nginx configuration file nginx.conf, the path is generally: /etc/nginx/nginx.conf
.
Add client_max_body_size 20m
to the http{}
segment; 20m is the maximum upload size allowed.
After saving, restart nginx, the problem is solved.