这不是全部代码,但我认为它是相关部分。如何为每个放入拖放区的文件动态创建单独的进度条?
function sendFile(file) {
xhr.upload.addEventListener('progress', function (ev) {
var bar = document.getElementById("progressBar");
progressBar.value += percentComplete;
}, false);
dropzone.ondrop = function (event) {
event.stopPropagation();
event.preventDefault();
var filesArray = event.dataTransfer.files;
for (var i = 0; i < filesArray.length; i++) {
sendFile(filesArray[i]);
//trigger progress bar with sendFile
document.getElementById('file').innerHTML += '<li>' + filesArray[i].name + ' ' + '<progress id="progressBar" value="0" max="100"></progress></div></li>';
}
}