问题
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