0

File upload progress bar with jQuery

halfer
  • 19,824
  • 17
  • 99
  • 186
Luke Wenke
  • 1,149
  • 2
  • 23
  • 43
  • This question appears to be just a pointer to another one, and as such is a duplicate. – halfer Jun 07 '19 at 17:32
  • Possible duplicate of [File upload progress bar with jQuery](https://stackoverflow.com/questions/15410265/file-upload-progress-bar-with-jquery) – halfer Jun 07 '19 at 17:32

1 Answers1

0

Here is the upload progress bar feature that I have got to know. Glad, If this helps you.

$.ajax({

  xhr: function() {
    var xhr = new window.XMLHttpRequest();
    xhr.upload.addEventListener("progress", function(evt) {
      if (evt.lengthComputable) {
        var percentComplete = evt.loaded / evt.total;
        percentComplete = parseInt(percentComplete * 100);
        console.log(percentComplete);
        if (percentComplete === 100) {
        }

      }
    }, false);

    return xhr;
  },
  url: posturlfile,
  type: "POST",
  data: JSON.stringify(fileuploaddata),
  contentType: "application/json",
  dataType: "json",
  success: function(result) {
    console.log(result);
  }
});
Sk. Irfan
  • 299
  • 3
  • 15