如何使用html5文件api提供取消上传选项 [英] How To provide Cancel upload option with html5 file api
本文介绍了如何使用html5文件api提供取消上传选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用html 5文件api ..上传文件,但是在进行中的事件中,我想取消上传,然后如何完成...我的代码是..
I am uploading file with html 5 file api..but in progress event i want to cancel the upload then how it can be done...my code is..
// Update progress bar
xhr.upload.addEventListener("progress", uploadProgress, false);
function uploadProgress(evt) {
if (evt.lengthComputable) {
var percentComplete = Math.round(evt.loaded * 100 / evt.total);
prognumber.innerHTML = percentComplete + ''%'';
//assign value to prgress bar Div
var progressBar = document.getElementById("progressBar");
progressBar.max = evt.total;
progressBar.value = evt.loaded;
}
}
// File load event
xhr.upload.addEventListener("load", loadSuccess, false);
function loadSuccess(evt) {
prognumber.innerHTML += "Upload";
}
我想提供取消上传选项...
I want to provide cancel upload option...
推荐答案
您可以在此处找到一种解决方案:http://www.matlus.com/html5-file-upload-with-progress/ [ http://en. lmgtfy.com/?q=upload+file+with+cancel+HTML5 [ ^ ].
—SA
You can find one of the solutions here: http://www.matlus.com/html5-file-upload-with-progress/[^].
As this is a very popular question, you can find a lot more: http://en.lmgtfy.com/?q=upload+file+with+cancel+HTML5[^].
—SA
这篇关于如何使用html5文件api提供取消上传选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文