I am uploading files and showing progress bars for each load, but it only applies to only one progress bar.
In html,
<input type="file" id="file-input" multiple>
<div id="file-list">
</div>
In Javascript,
$('#file-input').change(function(e) {
for (var i = 0, f; f = files[i]; i++) {
var reader = new FileReader();
reader.readAsBinaryString(f);
reader.onloadstart = function (e) {
var text = '<div><div id="progress_bar" class="loading"><div class="percent">0%</div></div></div>';
$('#file-list').append(text);
}
reader.onload = function(e) {
var progress = document.querySelector('.percent');
progress.style.width = '100%'; // replacing with percentage
progress.textContent = '100%';
}
}
});
The result for uploading three files at once is showing one progress bar with 100% and two bars with 0%. What's wrong with this?