Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plupload how to continue to upload after UploadComplete

I'm using plupload 1.5.7, jQuery Queue Widget, after the upload complete the Add files and Start Upload buttons disappear, replaced by a label Upload 1/1 files.

Now I can't add others files, I need to refresh the page and upload other files. I've tried also the uploader.splice() and uploader.refresh() methods without success.

Is it possible after an upload - of one or more files - to continue to upload?

My actual configuration is:

$("#uploader").pluploadQueue({
    // General settings
    runtimes: 'html5,gears,flash,silverlight,browserplus',
    url: '/upload.php',
    max_file_size: '10mb',
    chunk_size: '1mb',
    unique_names: true,

    // Specify what files to browse for
    filters: [
        {title : "Image files", extensions : "jpg,png"}
    ],

    // Flash settings
    flash_swf_url: '/assets/js/plupload/plupload.flash.swf',

    // Silverlight settings
    silverlight_xap_url: '/assets/js/plupload/plupload.silverlight.xap',

    init: {

        FilesAdded: function(up, files) {},
        UploadComplete: function(up, files) {
            up.splice();
            up.refresh();
        }
    }
});
like image 210
Massimiliano Marini Avatar asked May 22 '13 11:05

Massimiliano Marini


2 Answers

I use to proceed somewhat like this (sorry, can't test it right now), embedding my initialization code in a function which I can call whenever I want.

va initUploader = function () {
    $("#uploader").pluploadQueue({
        // General settings
        runtimes: 'html5,gears,flash,silverlight,browserplus',
        url: '/upload.php',
        max_file_size: '10mb',
        chunk_size: '1mb',
        unique_names: true,

        // Specify what files to browse for
        filters: [{
            title: "Image files",
            extensions: "jpg,png"
        }],

        // Flash settings
        flash_swf_url: '/assets/js/plupload/plupload.flash.swf',

        // Silverlight settings
        silverlight_xap_url: '/assets/js/plupload/plupload.silverlight.xap',

        init: {

            FilesAdded: function (up, files) {},
            UploadComplete: function (up, files) {
                // destroy the uploader and init a new one
                up.destroy();
                initUploader();
            }
        }
    });
};

$(document).ready(function(){initUploader();});
like image 99
jbl Avatar answered Oct 24 '22 04:10

jbl


The Buttons you're looking for are still available but not displayed. So instead of reinitializing the Uploader, you can just change the display CSS option via JS, like that:

uploader.bind('UploadComplete', function() {
  $(".plupload_buttons").css("display", "inline");
  $(".plupload_upload_status").css("display", "inline");
})

Or if you are attaching your Events in the init function:

UploadComplete: function() {
  $(".plupload_buttons").css("display", "inline");
  $(".plupload_upload_status").css("display", "inline");
}

Note that im using jQuery in this example, but it would also work with plain JS.

like image 22
mrusa Avatar answered Oct 24 '22 03:10

mrusa