上传文件失败 Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)
2017-03-17 15:33
951 查看
写了一个简单的文件上传页面,但是在上传较大文件(大于20M)时,网页上传后无任何提示。
打开控制台,发现报错如下:
Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)
简单来说呢,就是请求实体过大导致的错误。
我用的服务器是ngnix服务器,此时要做的就是修改配置啦。
打开nginx.conf配置文件,修改client_max_body_size值
加上下面这行:
client_max_body_size 30M(改成你想要的数值)
1.查找配置文件
find / -name nginx.conf
2.修改
vim nginx.conf
3.重新加载ngnix.conf
./nginx -s reload
然后就解决啦,文件上传成功!
另外附上其他类型服务器修改配置文件的办法:
Apache服务器
修改下Apache配置文件中的LimitRequestBody配置,如果是虚拟主机,请联系空间商帮助修改。
具体步骤:
在apache环境中上传较大软件的时候,有时候会出现413错误,出现这个错误的原因,是因为apache的配置不当造成的,找到apache的配置文件目录也就是conf目录,和这个目录平行的一个目录叫conf.d打开这个conf.d,里面有一个php.conf
目录内容如下:
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
LoadModule php4_module modules/libphp4.so
#
# Cause the PHP interpreter handle files with a .php extension.
#
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 6550000
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php
错误就发生在这个LimitRequestBody配置上,将这个的值改大到超过你的软件大小就可以了
如果没有这个配置文件请将
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 6550000
写到apache的配置文件里面即可。
IIS服务器(Windows Server 2003系统IIS6)
先停止IIS Admin Service服务,然后
找到windows\system32\inesrv\下的metabase.xml,打开,找到ASPMaxRequestEntityAllowed 修改为需要的值,然后重启IIS Admin Service服务
1、在web服务扩展 允许active server pages和在服务器端的包含文档
2、修改各站点的属性 主目录-配置-选项-启用父路径
3、使之可以上传大文档(修改成您想要的大小就可以了,以字节为单位)
c:\WINDOWS\system32\inetsrv\MetaBase.xml
!企业版的windows2003在第592行
默认的预设置值 AspMaxRequestEntityAllowed="204800" 即200K
将其加两个0,即改为,现在最大就可以上传20M了。
AspMaxRequestEntityAllowed="20480000"
打开控制台,发现报错如下:
Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)
简单来说呢,就是请求实体过大导致的错误。
我用的服务器是ngnix服务器,此时要做的就是修改配置啦。
打开nginx.conf配置文件,修改client_max_body_size值
加上下面这行:
client_max_body_size 30M(改成你想要的数值)
1.查找配置文件
find / -name nginx.conf
2.修改
vim nginx.conf
3.重新加载ngnix.conf
./nginx -s reload
然后就解决啦,文件上传成功!
另外附上其他类型服务器修改配置文件的办法:
Apache服务器
修改下Apache配置文件中的LimitRequestBody配置,如果是虚拟主机,请联系空间商帮助修改。
具体步骤:
在apache环境中上传较大软件的时候,有时候会出现413错误,出现这个错误的原因,是因为apache的配置不当造成的,找到apache的配置文件目录也就是conf目录,和这个目录平行的一个目录叫conf.d打开这个conf.d,里面有一个php.conf
目录内容如下:
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
LoadModule php4_module modules/libphp4.so
#
# Cause the PHP interpreter handle files with a .php extension.
#
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 6550000
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php
错误就发生在这个LimitRequestBody配置上,将这个的值改大到超过你的软件大小就可以了
如果没有这个配置文件请将
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 6550000
写到apache的配置文件里面即可。
IIS服务器(Windows Server 2003系统IIS6)
先停止IIS Admin Service服务,然后
找到windows\system32\inesrv\下的metabase.xml,打开,找到ASPMaxRequestEntityAllowed 修改为需要的值,然后重启IIS Admin Service服务
1、在web服务扩展 允许active server pages和在服务器端的包含文档
2、修改各站点的属性 主目录-配置-选项-启用父路径
3、使之可以上传大文档(修改成您想要的大小就可以了,以字节为单位)
c:\WINDOWS\system32\inetsrv\MetaBase.xml
!企业版的windows2003在第592行
默认的预设置值 AspMaxRequestEntityAllowed="204800" 即200K
将其加两个0,即改为,现在最大就可以上传20M了。
AspMaxRequestEntityAllowed="20480000"
相关文章推荐
- Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)
- Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)
- Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)
- 关于前台jsp页面Failed to load resource: the server responded with a status of 400 (Bad Request)
- Failed to load resource: the server responded with a status of 400 (Bad Request)
- Failed to load resource: the server responded with a status of 400 (Bad Request)
- 关于使用springmvc时Failed to load resource: the server responded with a status of 400 (Bad Request)错误可能原因
- Failed to load resource: the server responded with a status of 400 (Bad Request)
- ajaxSubmit 报错 400 (Failed to load resource: the server responded with a status of 400 (Bad Request))
- Failed to load resource: the server responded with a status of 400 (Bad Request)
- (springmvc)页面找不到静态资源文件Failed to load resource: the server responded with a status of 404 (Not Found)
- ajax 报错 400 (Failed to load resource: the server responded with a status of 400 (Bad Request))
- 关于使用springmvc时Failed to load resource: the server responded with a status of 400 (Bad Request)错误可能原因
- Failed to load resource: the server responded with a status of 404
- SrpingMVC==>Failed to load resource: the server responded with a status of 404(Not Found)
- springmvc Failed to load resource: the server responded with a status of 404 (Not Found)
- ripple Failed to load resource: the server responded with a status of 404 (Not Found)
- Failed to load resource: the server responded with a status of 500 (Internal Server Error)
- SprimgMVC:Failed to load resource: the server responded with a status of 406 (Not Acceptable)
- Failed to load resource: the server responded with a status of 406 (Not Acceptable)问题的解决方案