我正在一个项目(在Django中)中创建一个页面,以添加有关文件的数据信息,然后添加文件本身。
单击“更多数据集”按钮时,它将添加另一个字段以上传另一个文件。
可以一次性添加最终用户所需数量的文件。
我需要的是一旦单击“上传数据集”并应该显示单个进度条,就上传所有附件。
到目前为止,我已经看完了多个教程,但是使用Vitor Freitas的教程有点接近。
JS代码:
$(function(){
/*$("#add_new_dataset").click(function(){
$(".file").click();
});*/
$(".file").fileupload({
dataType: 'json',
sequentialUploads: true, /* Send the files one by one */
start: function(e){ /* When the upload process starts, show the modal */
$("#modal-progress").modal("show");
},
stop: function(e){ /* When the upload progress finalizes, hide the modal */
$("#modal-progress").modal("hide");
},
progressall: function(e, data){ /* Update the progress bar */
var progress = parseInt(data.loaded / data.total * 100, 10),
strProgress = progress + "%";
$(".progress-bar").css({"width": strProgress});
$(".progress-bar").text(strProgress);
},
done: function(e, data){
if(data.result.is_valid){
$("#gallery tbody").prepend(
"
" + data.result.name + "");
}
}
})