When the user's internet is connected, the upload is done and while uploading, the internet is suddenly disconnected and the form upload is failed.(status = (failed)net::ERR_INTERNET_DISCONNECTED , Type = xhr)
Is there a code that resumes the upload form after connecting to the Internet?
This is my upload code that is sent as Ajax:
$('#form_upload_create').submit(function (e) {
e.preventDefault();
$form = $(this)
var formData = new FormData(this);
$.ajax({
url: window.location.pathname,
type: 'POST',
data: formData,
cache: false,
contentType: false,
processData: false,
success: function (response) {
alert(response.message)
}
},
xhr: function () {
//upload Progress
var xhr = $.ajaxSettings.xhr();
if (xhr.upload) {
xhr.upload.addEventListener('progress', function (event) {
var percent = 0;
var position = event.loaded || event.position;
var total = event.total;
if (event.lengthComputable) {
percent = Math.ceil(position / total * 100);
}
//update progressbar
$(".progress-bar").css("width", +percent + "%");
$(".status").text(percent + "%" + 'waiting upload...');
}, true);
}
return xhr;
},
});
});