使用uploadify上传大文件报 IO error #2038错误的解决方案

一.问题说明:

    目前正在处理一个项目,需要上传视频文件,大小限制在100M以内。使用uploadify来上传视频,上传十几兆的视频能正常上传,但是上传四五十的文件就会报IO error #2038错误。

          错误截图:

   

二.解决办法:

    1.使用uploadify的javascript核心代码如下:

$("#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 添加如下代码,控制上传大小。

<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。

     

三.问题解决

     

 
posted @ 2014-09-03 16:42  FreeFunCode  阅读(4422)  评论(0编辑  收藏  举报