您的位置:首页 > 其它

IIS7.5只能上传2M,discuz论坛附件上传失败的解决办法

2011-05-03 20:05 441 查看
问题:IS7.5只能上传2M的数据,discuz论坛附件上传显示100%,然后显示上传失败,后台找不到附件。

网上一般解决方案:
IIS修改方案:

1. 修改IIS的applicationhost.config
打开 %windir%/system32/inetsrv/config/applicationhost.config
找到: <requestFiltering>节点,
这个节点默认没有 <requestLimits maxAllowedContentLength="上传大小的值(单位:byte)" /> 元素,IIS 7和IIS 7.5上测试过 最大值只能是<requestLimits maxAllowedContentLength="4294967295" /> <4GB,
为这个节点新增如下事例元素:<requestLimits maxAllowedContentLength="2147483647" /> ,上传的大小将改为2G
注意: %windir%/system32/inetsrv/config/applicationhost.config 文件一定不要用其他机器的文件替换,否则IIS将无法启动
此文件记录了,当前IIS中所有Site , App pool的信息,还有一些与机器相关的配置。
2 ..修改web.config
<system.web>
<httpRuntime executionTimeout="36000" maxRequestLength="2097151"/> <!--maxRequestLength:上传的大小,单位K ,executionTimeout:设置超时时间,单位:秒。(默认是90秒) -->
</system.web>

注意:这个maxRequestLength最大值只能是2097151K,设置大于这个值将会出现如下错误:

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: The value for the property 'maxRequestLength' is not valid. The error is: The value must be inside the range 0-2097151.
Source Error:
<httpHandlers />
<customErrors mode="RemoteOnly" />
<httpRuntime executionTimeout="36000" maxRequestLength="4194304" />
<authentication mode="Windows" />
<identity impersonate="true" />

3. web.config下如果有如下节点(此节点是为IIS 7设计的) ,则修改
<requestLimits maxAllowedContentLength="2147483647" /> 单位与applicationhost.config中的<requestLimits maxAllowedContentLength="2147483647" />一致,它的最大值也只能为4294967295
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483647" />
</requestFiltering>
</security>
</system.webServer>

PHP.INI修改方案:

修改PHP.INI
查找upload_max_filesize =2 M,改为20M。

已经根据网上很多方法,修改了PHP.INI和IIS的配置文件,还是不行的话,可以接着下面的方法修改。

修改PHP.INI:

查找max_execution_time = 30,更改为max_execution_time = 600 (响应时间,超过会出错,要改大)
查找max_input_time = 60,更改为max_input_time = 600
查找memory_limit = 8M ,更改为memory_limit = 20M (php的内存,太小了不够,要改大)
查找display_errors = On,更改为display_errors = Off
查找register_globals = Off,更改为register_globals = On
查找post_max_size = 8M,更改为post_max_size = 20M (主要的)
查找upload_max_filesize = 2M,更改为upload_max_filesize = 20M (主要的)
这样就可以了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐