当前位置 主页 > iis相关 >

    怎么修改iis7默认文件上传大小?

    栏目:iis相关 时间:2018-10-05 13:44

      IIS7默认文件上传大小是30M,那么超过30M的文件就无法上传了,那么就需要对IIS的配置文件进行修改。
     
      在实际应用中往往会出现上传文件太大,无法上传的情况,那是因为IIS对上传文件大小有限制,IIS7默认文件上传大小是30M,要突破这个限制需要做一下修改:
     
      1、打开%windir%\system32\inetsrv\config\applicationhost.config找到:<requestFiltering>节点
     
      这个节点默认没有<requestLimitsmaxAllowedContentLength="上传大小的值(单位:byte)"/>元素,IIS7和IIS7.5上测试过最大值只能是<requestLimitsmaxAllowedContentLength="4294967295"/><4GB,
     
      为这个节点新增如下事例元素:<requestLimitsmaxAllowedContentLength="2147483647"/>,上传的大小将改为2G
     
      注意:%windir%\system32\inetsrv\config\applicationhost.config文件一定不要用其他机器的文件替换,否则IIS将无法启动此文件记录了,当前IIS中所有Site,Apppool的信息,还有一些与机器相关的配置。
     
      2、修改web.config
     
      <system.web>
     
      <httpRuntimeexecutionTimeout="36000"maxRequestLength="2097151"/>
     
      <!--maxRequestLength:上传的大小,单位K,executionTimeout:设置超时时间,单位:秒。(默认是90秒)-->
     
      </system.web>
     
      3、web.config下如果有如下节点(此节点是为IIS7设计的),则修改:
     
       
     
      <requestLimitsmaxAllowedContentLength="2147483647"/>单位与applicationhost.config中的<requestLimitsmaxAllowedContentLength="2147483647"/>一致,它的最大值也只能为4294967295<system.webServer>
     
      <security>
     
      <requestFiltering>
     
      <requestLimitsmaxAllowedContentLength="2147483647"/>
     
      </requestFiltering>
     
      </security>
     
      </system.webServer>