0
嗨我试图上传一个2文件或更多,我的问题是我的进度条会说100%,因为小文件上传第一,然后它回到百分之的大文件..我的问题是如何我可以有同样的进展,如果我有很多文件被上传?ajax进度条上传2个文件或更多
$('body').on('change', 'input:file.gallery_images', function(event)
{
event.preventDefault();
var data = new FormData();
data.append('id', $("#id").val());
var count = $(this)[0].files.length;
$.each($(this)[0].files, function(i, file)
{
data.append('userfile', file);
$.ajax(
{
type: "POST",
url: href+path+"/imagens/store",
data: data,
mimeType: 'multipart/form-data',
contentType: false,
cache: false,
processData: false,
dataType: "json",
xhr: function()
{
var _xhr = $.ajaxSettings.xhr();
_xhr.addEventListener('progress', function (event) { }, false);
if (_xhr.upload)
{
_xhr.upload.onprogress = function(event)
{
var percent = 0;
if (event.lengthComputable)
{
var position = event.position || event.loaded;
var total = event.totalSize || event.total;
percent = Math.ceil(position/total * 100);
}
$("#progress-bar").width(percent + '%');
};
}
return _xhr;
},
beforeSend: function()
{
$("#progress").fadeIn('slow');
$("#progress-bar").width('0%');
},
success: function(data)
{
if(data.gallery)
{
if($(".alert").length > 0)
{
$(".alert").hide('slow').remove();
$("#droppable").show('slow');
}
$('.gallery').fadeTo('300', '0.5', function() {
$(this).html($(this).html() + data.gallery).fadeTo('300', '1');
});
}
$("#progress").fadeOut('slow');
}
});
});
});
的 '身份证',我派是一样的。此方法无效。同样的事情发生。只有酒吧才会出现。 –
我也不知道倒退的原因,但值得注意的是,不值得询问投票决定 - 选民将会很久以前继续前进。出于这个原因,并且由于大多数读者不登录或投票,我们宁愿投票评论也不会编辑到这里的帖子中。如果你真的想问一下这个问题,那就留下评论吧,尽管充其量你会从没有投票的人那里得到猜测。 – halfer