Click here to Skip to main content
15,889,403 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
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...
Posted
Updated 2-Dec-11 1:40am
v2
Comments
Sergey Alexandrovich Kryukov 2-Dec-11 10:21am    
Broken Google again?
--SA

1 solution

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
 
Share this answer
 
v2
Comments
Amir Mahfoozi 21-Dec-11 2:23am    
+5. If it was possible I +100'ed it =)) "lmgtfy.com" was very funny ;) specially for some people who come here before googling the problem.
Sergey Alexandrovich Kryukov 21-Dec-11 11:50am    
Right. Thank you, Amir.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900