[Asp.net]Uploadify上傳大文件

引言

之前使用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.

發佈了30 篇原創文章 · 獲贊 16 · 訪問量 20萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章