I have a form to submit file,my html code is here:
<input type="file" name="file" id="file">
<button onclick="upload()">upload</button>
and I have axios code to upload,such as this code
function upload() {
var file = $('#file').prop('files')[0];
var formdata = new FormData;
formdata.append('file',file);
const config = {
onUploadProgress: function(progressEvent) {
var percentCompleted = Math.round( (progressEvent.loaded * 100)
/ progressEvent.total );
console.log(percentCompleted)
}
};
axios.post("/upload/test", formdata, config,{
headers: {
'Content-Type': 'multipart/form-data'
}
})
}
I can get percent of upload in console,But I don't know How I can show this in progress bar,Can you help me?