1

我正在尝试从 jsfiddle 示例jsfiddle-plupload中进行 plupload 工作

但这对我来说不起作用,如果块被跳过下面的 statechange 事件是代码

function validClasses()
{
    datas=[];
                    $('#uids li').each(function() {
                        var data = { 
                            className: $(this).attr("id")
                        };
                        datas.push(data);
                     });
    if(datas.length>0)
        {
            return true;
        }else{
            alert('error');
            return false;
        }
}
         var uploadInitialized = false;
        function plupload(){ 

          var uploader = $("#uploader").pluploadQueue({
        // General settings
            runtimes: 'html5,html4',
            url: 'fileUpload.htm',
            max_file_size: '200mb',
            chunk_size: '1mb',
            unique_names: true,
            multiple_queues: true,
            multipart_params: {
                "name": $("#name").val()
            },
            // Specify what files to browse for
            filters: [
                {
                title: "Image files",
                extensions: "jpg,gif,png,eps,jpeg,pdf,tiff,tif"},
            {
                title: "Zip files",
                extensions: "zip"}
            ],
            init: {
                StateChanged: function(up) {
                    if (!uploadInitialized && up.state == plupload.STARTED) {
                        if (!validClasses()) {
                            up.stop();
                        } else {
                            uploadInitialized = true;
                        }
                    }
                },
                BeforeUpload: function(up, file) {
                    up.settings.multipart_params = {'name': $('#name').val()}
                }
            }
        });
   }

请注意,在 jsfiddle 示例中,上传刚刚停止,也就是说我可以上传而无需再次添加文件。在我这边,开始上传按钮消失了,文件在列表中,但按钮消失了。我正在获取上传状态而不是按钮,如果上传也停止,我希望按钮在那里。我的意思是在 StateChanged 中我直接写了 up.stop() ,这也不起作用。任何人请帮忙。谢谢。

4

0 回答 0