Skip to content

Instantly share code, notes, and snippets.

@mtyaka
Created August 27, 2012 12:56
Show Gist options
  • Save mtyaka/3488217 to your computer and use it in GitHub Desktop.
Save mtyaka/3488217 to your computer and use it in GitHub Desktop.
uploader.destroy();
uploader = new plupload.Uploader({
runtimes : 'silverlight',
browse_button : 'pickfiles',
container : 'container',
max_file_size : '20mb',
url : '/upload/to_gallery?gallery=3656601', // <-- change gallery_id here
flash_swf_url : '/plupload/plupload.flash.swf',
silverlight_xap_url : '/plupload/plupload.silverlight.xap',
filters : [
{title : "Image files", extensions : "jpg,gif,png"}
],
resize : {width : 3000, height : 3000, quality : 95}
});
uploader.bind('Init', function(up, params) {
$('#filelist').html("<div>Current runtime: " + params.runtime + "</div>");
});
uploader.init();
uploader.bind('FilesAdded', function(up, files) {
$.each(files, function(i, file) {
$('#filelist').append(
'<div id="' + file.id + '">' +
file.name + ' (' + plupload.formatSize(file.size) + ') <b></b>' +
'</div>');
});
up.refresh(); // Reposition Flash/Silverlight
up.start();
});
uploader.bind('UploadProgress', function(up, file) {
$('#' + file.id + " b").html(file.percent + "%");
});
uploader.bind('Error', function(up, err) {
$('#filelist').append("<div>Error: " + err.code +
", Message: " + err.message +
(err.file ? ", File: " + err.file.name : "") +
"</div>"
);
up.refresh(); // Reposition Flash/Silverlight
});
uploader.bind('FileUploaded', function(up, file) {
$('#' + file.id + " b").html("100%");
window.opener.px_refresh_lightbox();
if (up.total.queued === 0) uploadContinueDialog();
});
var orig_trig = uploader.trigger;
uploader.trigger = function(name) {
console.log(name);
return orig_trig.apply(uploader, arguments);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment