jQuery File Upload blueimpl浏览器冻结

use*_*410 5 jquery file-upload blueimp

我正在使用Jquery File Upload bluempl上传文件。当我使用此插件上传大量文件(如6000个文件)时,浏览器会挂起并冻结很多次,尽管在访问服务器/文件中的文件夹时,我仍可以看到文件已上传。您能否告诉我在不冻结浏览器的情况下可以用于上传许多文件的优化或参数类型。我以示例文件的basic.hml中的示例为例:

$(function () {
    'use strict';
    // Change this to the location of your server-side upload handler:
    var url = window.location.hostname === 'blueimp.github.io' ?
                '//jquery-file-upload.appspot.com/' : 'server/php/';
    $('#fileupload').fileupload({
        url: url,
        dataType: 'json',
        done: function (e, data) {
            $.each(data.result.files, function (index, file) {
                $('<p/>').text(file.name).appendTo('#files');
            });
        },
        progressall: function (e, data) {
            var progress = parseInt(data.loaded / data.total * 100, 10);
            $('#progress .progress-bar').css(
                'width',
                progress + '%'
            );
        }
    }).prop('disabled', !$.support.fileInput)
        .parent().addClass($.support.fileInput ? undefined : 'disabled');
});
Run Code Online (Sandbox Code Playgroud)

提前致谢。

Gun*_*nar 0

看起来同步上传是blueimp 中的默认设置。

浏览器冻结通常与同步而不是异步 JavaScript 请求有关。

Blueimp 描述了如何异步上传: https://github.com/blueimp/jQuery-File-Upload/wiki/Submit-files-asynchronously

更新

  1. 好的,上面页面描述的 add 方法只是在文件添加到队列时调用

  2. 选项文档包含参数sequentialUploadslimitConcurrentUploads,请尝试使用它们或其中之一。