萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 網路安全 >  >> 網路應用技術 >> 應用程式教學

IIS 7 上傳超過 30MB 視頻報「找不到文件或目錄」解決方法

IIS 7 默認限制上傳文件大小為 30MB(maxAllowedContentLength = 30000000 字節),超過即報 404 或「找不到文件或目錄」。本文演示修改 IIS_schema.xml 突破限制的完整步驟。

核心修改:調整 requestLimits/maxAllowedContentLength

  1. 獲取文件控制權:
    路徑:C:\Windows\System32\inetsrv\config\schema\IIS_schema.xml
    右鍵屬性 → 安全 → 高級 → 所有者 → 選 Administrators → 確定 → 權限編輯 → Administrators 給予「完全控制」 → 取消「只讀」屬性。
  2. 編輯配置:
    用記事本打開 IIS_schema.xml,搜索 30000000(約第 1024 行),修改為所需值(如 300000000 = 300MB)。
    關鍵片段:
<element name="requestLimits">
  <attribute name="maxAllowedContentLength" type="uint" defaultValue="300000000" />
  <attribute name="maxUrl" type="uint" defaultValue="4096" />
  <attribute name="maxQueryString" type="uint" defaultValue="2048" />
  ...

配合應用層配置(雙重保障)

除 IIS 級別,應用程序 web.config 亦需放開限制:

<system.webServer>
  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="300000000" />
    </requestFiltering>
  </security>
</system.webServer>

<system.web>
  <httpRuntime maxRequestLength="307200" executionTimeout="300" /> <!-- KB單位,300MB -->
</system.web>

生效驗證

  1. 保存所有修改,CMD 運行 iisreset 重啟 IIS。
  2. 測試上傳 >30MB 文件,確認不再報 404/找不到目錄。

注意:修改系統配置文件有風險,操作前務必備份 IIS_schema.xml。生產環境建議配合應用層 web.config 設置,避免系統更新覆蓋導致失效。

copyright © 萬盛學電腦網 all rights reserved