Plupload多个实例

时间:2011-09-09 12:10:48

标签: plupload

我正在尝试在页面上设置未知数量的plupload实例。我需要动态添加更多实例并删除和重置其中的一些实例。我有一般的想法,但没有任何作用。

我的一次尝试是jsfiddle

感谢您的帮助。

代码:

var uploaders = new Array();

initUploaders = function(uploaders) {
    console.log("initUploaders()");
    $(".gallery").each(function() {
        var el = $(this);
        var button = el.attr("id") + "_uploader";
        console.log("Init uploader id:" + el.attr("id"));
        var uploader = new plupload.Uploader({
            runtimes: 'gears,html5,flash,silverlight,browserplus',
            browse_button: button,
            max_file_size: '10mb',
            url: 'ModuleGallery/Upload/',
            flash_swf_url: 'http://static.srv42.net/plupload/js/plupload.flash.swf',
            silverlight_xap_url: 'http://static.srv42.net/plupload/js/plupload.silverlight.xap',
            filters: [
                {
                title: "Image files",
                extensions: "jpg,gif,png"}
            ]
        });        

        uploader.bind('FilesAdded', function(up, files) {
            uploader.start();
        });

        uploader.init();    
        galleryUploaders.push(uploader);
    };

    initUploaders(uploaders);

2 个答案:

答案 0 :(得分:8)

最后答案很简单。您可以正常实例化它并绑定到QueueChanged事件。

uploader.bind('QueueChanged', function (up, files) {
     uploader.start();
     up.refresh();
});

答案 1 :(得分:2)

试试这个解决方案。您可以拥有n个实例数: