文件上传报错 Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)

问题:

Ajax+php 上传图片是报错:

Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)…

在这里插入图片描述

  1. 先翻译一下:
    在这里插入图片描述

  2. 通过翻译也看出了:是上传的文件太大,但是上传的文件大小。
    其实直接通过413就能看出报错的原因。
    在这里插入图片描述

    了解更多状态码:https://tool.oschina.net/commons?type=5

  3. 这里我使用的是之前提到的公司网站,修改图片的时候,上传报错。
    这个错误的原因是上传的图片超出了nginx配置的限制。

解决:

  1. 修改nginx.conf文件 ,100M应该是足够了
    location / {
    	client_max_body_size  100M; #添加这一行代码
    	index  index.php index.html index.htm;
    }
    
  2. 然后记得终端命令行重启:
    /usr/local/nginx/sbin/nginx -s reload
    
  3. 文件所在的目录
    在这里插入图片描述
    在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_44009311/article/details/106630156