6

我正在使用 plupload 1.5.7,jQuery Queue Widget,上传完成后Add filesStart Upload按钮消失,取而代之的是一个标签Upload 1/1 files

现在不能添加其他文件,需要刷新页面,上传其他文件。我也尝试了uploader.splice()uploader.refresh()方法,但没有成功。

上传一个或多个文件后是否可以继续上传?

我的实际配置是:

$("#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();
        }
    }
});
4

2 回答 2

7

我过去常常像这样进行(抱歉,现在无法测试它),将我的初始化代码嵌入到我可以随时调用的函数中。

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();});
于 2013-05-22T11:43:34.473 回答
4

您要查找的按钮仍然可用,但未显示。因此,您可以通过 JS 更改显示 CSS 选项,而不是重新初始化 Uploader,如下所示:

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

或者,如果您在 init 函数中附加您的事件:

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

请注意,我在此示例中使用 jQuery,但它也适用于纯 JS。

于 2014-07-25T09:26:24.313 回答