使用uploadify上傳大檔案報 IO error #2038錯誤的解決方案
阿新 • • 發佈:2019-02-07
一.問題說明:
目前正在處理一個專案,需要上傳視訊檔案,大小限制在100M以內。使用uploadify來上傳視訊,上傳十幾兆的視訊能正常上傳,但是上傳四五十的檔案就會報IO error #2038錯誤。
錯誤截圖:
二.解決辦法:
1.使用uploadify的javascript核心程式碼如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
$( "#uploadify" ).uploadify({
'uploader' : '@Url.Content("../Content/uploadify/uploadify.swf")' ,
'script' : '@Url.Content("../Content/uploadify/UploadHandler.ashx")' ,
//
'scriptData': { 'fname': fname },//帶引數
'cancelImg' : '@Url.Content("../Content/uploadify/cancel.png")' ,
'folder' : '@Url.Content("~/Models/Video/movies")' ,
'queueID' : 'fileQueue' ,
'method' : "get" ,
'removeCompleted' : false ,
'auto' : true , //自動上傳
'preventCaching' : true ,
'multi' : false ,
'buttonText' : "瀏覽並上傳作品" ,
'fileExt' : "*.flv;*.mp4;*.mpeg;*.mov;*.wmv;*.avi;*.swf" , //限制上傳格式
'fileDesc' : "*.flv;*.mp4;*.mpeg;*.mov;*.wmv;*.avi;*.swf" ,
'sizeLimit' :
102400000, //限制大小 'onComplete' : function (event,
queueID, fileObj, response, data) {
if (response
!= null )
{
if (response
== "0" )
{
$.messager.alert( '溫馨提示' , '視訊格式不符合參賽要求,請選擇格式為avi、mp4、mov、flv、mpeg、wmv、flash等格式的視訊作品!' );
} else {
$.messager.alert( "溫馨提示" , "作品已成功上傳,請點選確定儲存作品相關資訊" );
$( "#path" ).val(response);
}
} else
{
$.messager.alert( "溫馨提示" , "後臺未返回正常引數,請確認是否上傳" );
}
},
'onError' : function (event,
queueID, fileObj, errorObj) {
alert(errorObj.type
+ "Error:" +
errorObj.info);
}
});
|
2.web.config 新增如下程式碼,控制上傳大小。
1 2 3 |
<system.web>
<httpRuntime
requestValidationMode= "4.0" maxRequestLength= "102400000" executionTimeout= "110"
</system.web>
|
3.上面1,2步驟我們都是在程式中限制上傳大小,但是伺服器IIS7版本下上傳檔案大小預設是30M以內,所以專案部署後,最終我們程式上傳超過30M還是會報錯IO error #2038錯誤,下面來修改IIS上傳限制大小。
1).開啟IIS管理器,找到Default Web Site。先進行停止。然後 在IIS中雙擊“請求篩選”開啟。
2).點選右邊的“編輯功能設定”,開啟“編輯請求篩選設定”對話方塊。其中的允許的最大容量長度,預設是”30000000“,30M,將其修改為你所需要的大小即可。然後 啟動IIS。
三.問題解決