Doubts about input uploaded by H5

Why is it that when I call FileReader"s onprogressAPI to set the progress, the upload will get stuck in the middle of the upload, and then finish it directly after a while?

question code is as follows:

     var reader = new FileReader();
     reader.onprogress = function(ev) {
         setTimeout(function(){ hr.style.width = parseInt(ev.loaded*100 / ev.total) + "%"; }, 1)
         pro.value = ev.loaded;
     }
     reader.readAsDataURL(upload.files[0]);

I want to change the progress bar according to the actual progress.

May.22,2021

what exactly do you mean by stuck?


whether the uploaded file is not large enough and is local, so immediately upload
try to upload a larger file from the local to the extranet server

.
Menu