Plupload multiple instances

☆樱花仙子☆ 提交于 2019-12-06 04:33:59

问题


I'm trying to set up unknown number of plupload instances on page. I need to dynamically add more instances and remove and reset some of them. I have the general idea, but nothing works.

One of my tries is on jsfiddle.

Thank you for all the help.

Code:

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);

回答1:


The answer was pretty simple in the end. You can instance it normally and just bind to QueueChanged event.

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



回答2:


Try this solution. You can have n number of instances with this:

  • Multiple Instances of Plupload - jSFiddle


来源:https://stackoverflow.com/questions/7361434/plupload-multiple-instances

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!