读书人

Jquery.uploadify在遨游中多选文件上传

发布时间: 2012-04-05 12:42:40 作者: rapoo

Jquery.uploadify在遨游中多选文件上传第一个后停止,IE正常,已经尝试了uploadify.swf?V='+(new Date()).getTim
请大家帮忙谢谢,遨游多文件上传不可用只能传成功第一个,就终止了,之后就没响应了,IE8多文件上传好使,该引用的JS都引用了v2.1.4.min.js版本,代码如下:

JScript code
//按钮触发保存文件        function SaveFile() {            var strPath = $("#txtParent_2").html();            strPath = '../UserFile/InfoManage/' + strPath;            var strID = $("#txtID").val();            var strUserID = $("#txtUserID").val();            var strCorpCode = $("#txtCorpCode").val();            var strScript = '../CheckCode/FileManage.aspx?Mode=AddFile&DirID='+strID+"&Corp="+strCorpCode+"&UserID="+strUserID;            //'script': '../CheckCode/FileManage.aspx?Mode=AddFile&DirID='+$("#txtID").val(),            $('#uploadify').uploadifySettings('script', strScript);            //'folder': '../UserFile/'+strPath,              $('#uploadify').uploadifySettings('folder', strPath);            $('#uploadify').uploadifyUpload();            document.getElementById('apDiv8').style.display = "none";            document.getElementById('divUpFile').style.display = "none";        }$(document).ready(function() {            $("#uploadify").uploadify({                'uploader': '../../Js/JQuery/uploadify.swf?V='+(new Date()).getTime(),                'height': '26',                'width': '74',                'buttonImg': '../../Images/Manage/xzwj.jpg',                'cancelImg': '../../Images/Manage/cancel.png',                'queueID': 'fileQueue',                //'fileDesc': '*.rar;*.jpg;*.gif',                  //'fileExt': '*.rar;*.jpg;*.gif',                  'sizeLimit': '400097152', //400M                  'auto': false,                'multi': true,                'onError': function(a, b, c, d) {                    if (d.status == 404)                        alert('Could not find upload script.');                    else if (d.type === "HTTP")                        alert('error ' + d.type + ": " + d.status);                    else if (d.type === "File Size")                    { }                 },                'onComplete': function(event, queueID, fileObj, response, data) {                    if (response == "0") {                        alert("上传附件出错,请重试");                        return;                    }                    var strName = fileObj.name;                    /*iNum++;                    var len = fileObj.size;                    len = Math.round(len/1024*100)*0.01;                    var m="KB";                    if(len>1000)                    {len=Math.round(len*0.001*100)*0.01;m="MB";}                    len = len.toString() + m;                    var htm="<div id=\"fileItem"+iNum+"\"><img src=\"../../Images/Manage/fj.jpg\" alt=\"附件\" border=\"0\" />"+fileObj.name+"("+len+")    <a href=\"javascript:void(0);\" onclick=\"DelFile("+iNum+",'" + escape(strName)+"','../UserFile/"+strID+"')\"><img src=\"../../Images/Manage/sc.gif\" alt=\"删除\" border=\"0\"/></a></div>";                                        $("#fileUploaded").append(htm);*/                    document.getElementById("fileQueue").style.display = "none";                    var txtFileID = $("#txtTmp").val();                    $("#txtTmp").val(txtFileID + "," + response);                    var iTmp = strName.lastIndexOf(".");                    if (iTmp > 0) {                        strName = strName.substring(0, iTmp);                    }                    AddFileInfo(response, strName);                }            });});  



[解决办法]
uploadify.swf是flex制作的,利用里面的FileReferenceList控件,但是这个控件在多文件上传时,是遍历文件并单个请求上传,也就是同时上传多个文件,多次请求aspx.ashx,但是aspx/ashx每次只能接收到一个,是多次完成的。

至于你这句 'uploader': '../../Js/JQuery/uploadify.swf?V='+(new Date()).getTime(),
加上getTime()等于没加,你在ready事件中getTime只执行了一次,没有差别


[解决办法]
探讨

谢谢,我的邮箱是:hanguoji@vip.qq.com 主要是这次附带了几个参数,所以不能再ready中直接配置好:
var strScript = '../CheckCode/FileManage.aspx?Mode=AddFile&DirID='+strID+"&Corp="+strCorpCode+"&UserID="+strUserID;
……

读书人网 >asp.net

热点推荐