上传不自动上传队列中的所有文件

时间:2012-07-25 13:20:44

标签: jquery uploadify

我有一个uploadify问题,它不会自动上传队列中的所有文件。要么我没有正确地将它们添加到队列中,要么我错过了一些东西。当我点击上传按钮时,我真的希望上传队列中的所有文件,但是每次上传完成后我都要点击上传按钮。

按钮代码:

<div id="some_file_queue"></div>
<input type="file" name="batchImport" id="batchImport"/>
<input type="button" class="batchImport" value="Upload Files">

的javascript:

$("#batchImport").uploadify({
                'queueSizeLimit':10,
                'queueID':'some_file_queue',
                "swf":"/js/uploadify-v3.1/uploadify.swf",
                "uploader":"/js/uploadify-v3.1/uploadify.php",
                "uploadFolder":"/uploads/",
                "auto":false,
                "multi":true,
                "height":19,
                "width":94,
                "onUploadError":function(file,errorCode,errorMsg,errorString){
                    alert("The file " + file.name + " could not be uploaded: " + errorString);
                },
                "onQueueComplete":function(queueData){
                    console.log(queueData);
                },
                "onUploadSuccess":function(file, data, response){
                    $.ajax({
                        type:"POST",
                        data:{
                            single:1,
                            file:file,
                            data:data,
                            call:'element',
                            objContainer:$('select[name="objContainer"] option:selected').val()
                        },
                        url:"/index.php/upload_handler/handler",
                        success:function(response){
                            checkResponse(response);
                        }
                    });
                }
            });

            $(document).on("click",".batchImport",function(){
                $("#batchImport").uploadifyUpload("*");
            });

3 个答案:

答案 0 :(得分:2)

如果你按照以下方式设置auto:true: http://www.uploadify.com/documentation/uploadify/auto/ 文件将自动上传。

答案 1 :(得分:1)

我相信你在寻找:

$("#batchImport").uploadify('upload','*');
在uploadify的网站上

Live DEMO

答案 2 :(得分:-1)

你应该在你的javascript代码中放置“auto”:true ..然后它的工作..

$( “#batchImport”)。uploadify({                 'queueSizeLimit':10,                 'queueID': 'some_file_queue',                 “SWF”: “/ JS / uploadify-V3.1 / uploadify.swf”                 “上传”: “/ JS / uploadify-V3.1 / uploadify.php”                 “uploadFolder”: “/上传/”,                 的 “自动”:真,                 “多”:真实,                 “高度”:19,                 “宽度”:94,                 “onUploadError”:功能(文件,的errorCode,ERRORMSG,Errorstring,则){                     alert(无法上传“文件”+ file.name +“:”+ errorString);                 },                 “onQueueComplete”:功能(queueData){                     的console.log(queueData);                 },                 “onUploadSuccess”:函数(文件,数据,响应){                     $就({                         键入: “POST”,                         数据:{                             单:1,                             文件:文件,                             数据:数据,                             叫:“元素”,                             objContainer:$('select [name =“objContainer”]选项:selected')。val()                         },                         URL: “/ index.php文件/ upload_handler /处理程序”,                         成功:功能(响应){                             checkResponse(响应);                         }                     });                 }             });

        $(document).on("click",".batchImport",function(){
            $("#batchImport").uploadifyUpload("*");
        });