0

Jquery progrees Percentage bar goes 100% very Fast while uploading File.Uploading Completed in 10sec but progress perc reach 100% in 1sec. Please help me From this.

$("#regfrm").submit(function(e){
   var formObj = $(this);
   var formURL = formObj.attr("action");
   var formData = new FormData(this);
   console.log(formData);
   $.ajax({
      url: formURL,
      type: 'POST',
     data:  formData,
            mimeType:"multipart/form-data",
            contentType: false,
            processData:false,
            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);
                        alert(percentComplete);
                        $('.myprogress').text(percentComplete + '%');
                        $('.myprogress').css('width', percentComplete + '%');
                    }
                }, false);
                return xhr;
            },
            success: function(data, textStatus, jqXHR)
            {
                alert(data)
            },
            error: function(jqXHR, textStatus, errorThrown) 
            {
                alert('something wrong')
            }          
            });
            e.preventDefault();
        });
Joker
  • 111
  • 2
  • 9
  • you have too add beforeSend and uploadProgress like this: http://stackoverflow.com/questions/15410265/file-upload-progress-bar-with-jquery – Abanoub Makram Apr 04 '17 at 13:56
  • 2
    Possible duplicate of [File upload progress bar with jQuery](http://stackoverflow.com/questions/15410265/file-upload-progress-bar-with-jquery) – Marc L. Apr 04 '17 at 16:19

0 Answers0