Guest User

Guest User

  • Tech Writer
  • 515
  • 46.4k

Play/Pause functionality of File Upload in MVC

Jul 27 2020 4:24 PM
hello everyone,
 
I am uploading file with progress bar in my MVC app.
 
I want play/pause functionality to play or pause large files while uploading.
 
So that user can cancel or continue uploading that file.
 
My Code to upload and show progress bar is :
  1. function UploadFile() {  
  2. var files = $("#fileuploadInput").get(0).files;  
  3. counter = 0;  
  4. // Loop through files  
  5. for (var i = 0; i < files.length; i++) {  
  6. var file = files[i];  
  7. var formdata = new FormData();  
  8. formdata.append("fileuploadInput", file);  
  9. var ajax = new XMLHttpRequest();  
  10. ajax.upload.addEventListener("progress", progressHandler, false);  
  11. ajax.addEventListener("load", completeHandler, false);  
  12. ajax.addEventListener("error", errorHandler, false);  
  13. ajax.addEventListener("abort", abortHandler, false);  
  14. ajax.open("POST""http://localhost:56120/Handlers/Fileuploadhandler.ashx");  
  15. ajax.send(formdata);  
  16. }  
  17. }  
Thank you

Answers (1)