var xhr = new XMLHttpRequest();
xhr.open('PUT', fileUploadUrl, true);
xhr.onload = function (e) {
console.log('上传成功', xhr.status, xhr.statusText);
};
xhr.upload.onprogress = function(e){
if(e.lengthComputable){
console.log('当前上传进度'+Math.round((e.loaded/e.total)*100)+'%')
}
};
xhr.onerror = function (e) {
console.log('上传出错', xhr.status, xhr.statusText);
};
xhr.send(file);
前端:获取上传文件进度
最新推荐文章于 2024-07-01 12:15:20 发布