1. 程式人生 > >解決 [Asp.net]Uploadify上傳大檔案 報Http error 404 問題

解決 [Asp.net]Uploadify上傳大檔案 報Http error 404 問題

引言

之前使用Uploadify做了一個上傳圖片並預覽的功能,今天在專案中,要使用該外掛上傳大檔案。之前弄過上傳圖片的demo,就使用該demo進行測試。可以檢視我的這篇文章: [Asp.net]Uploadify所有配置說明,常見bug問題分析 。

大檔案上傳

第一步:修改uploadify引數

1             'fileSizeLimit': '0',//單個檔案大小,0為無限制,可接受KB,MB,GB等單位的字串值
2             'fileTypeDesc': '檔案',//檔案描述Image Files
3             'fileTypeExts': '
*.zip; *.rar; *.png',//允許上傳的檔案型別

測試,用一個大於30M的檔案,進行上傳測試。 

第二步:修改web.config

1 <configuration>
2   <system.web>
3     <compilation debug="true" targetFramework="4.5" />
4     <!--maxRequestLength就是檔案的最大字元數,最大值不能超過2個G左右,executionTimeout是超時時間--> 
5     <httpRuntime targetFramework
="4.5" maxRequestLength="1073741824" executionTimeout="3600" />
6 </system.web> 7 </configuration>

測試,仍使用上面的檔案,進行上傳測試。

第三步:新增system.webServer節點

 1 <configuration>
 2   <system.web>
 3     <compilation debug="true" targetFramework="4.5" />
 4     <!--maxRequestLength就是檔案的最大字元數,最大值不能超過2個G左右,executionTimeout是超時時間
-->
5 <httpRuntime targetFramework="4.5" maxRequestLength="1073741824" executionTimeout="3600" /> 6 </system.web> 7 <system.webServer> 8 <security> 9 <requestFiltering> 10 <!--修改伺服器允許最大長度--> 11 <requestLimits maxAllowedContentLength="1073741824"/> 12 </requestFiltering> 13 </security> 14 </system.webServer> 15 </configuration>

測試,仍然用上面的檔案,進行上傳測試:

設定IIS

 開啟IIS管理器,找到Default Web Site。先進行停止。

在IIS中雙擊“請求篩選”開啟。

點選右邊的“編輯功能設定”,開啟“編輯請求篩選設定”對話方塊。

其中的允許的最大容量長度,預設是”30000000“,30M,將其修改為1073741824,即1G。

啟動IIS.

 總結

在專案中遇到了這樣的問題,也花了點時間找解決方案,覺得既然花費了時間去找解決方案,就有必要總結一下,希望能幫到遇到同樣問題的你。 這裡不再提供demo,以可以從我上篇文章中下載,注意修改的地方已在本文章說明。