I'm trying to create a proper progress bar for my excel file upload in Laravel
I'm using ajax to upload the file and have gotten the progress bar for the upload part to "kind off" work. My only problem, is that when the file is uploaded (100% complete on the upload part) it still says "uploading...". It looks like uploadProgress
is not jumping forward to success
when it's done.
The file is processed in the back by laravel-excel, and it takes a very very long time to process big excel files with 1M+ rows.
Here is also a screenshot of it. I console logged the progress and it all went fine until it should go over to the success
function in the ajax call.
What could I do to fix this? To limit the amount of rows in the excel file uploads are not something I can do as the website I'm creating has the need to upload files that has this many or more rows.
Also, my code for the ajax upload:
// AJAX form upload
var form = $('.form-import');
var bar = $('.import-progress-bar');
var status = $('.import-status');
form.ajaxForm({
beforeSend: function() {
status.empty();
bar.attr('value', 0);
},
uploadProgress: function(event, position, total, percentComplete) {
bar.attr('value', percentComplete);
status.html('Uploading...');
console.log('Upload progress - '+ percentComplete + '%');
},
success: function() {
status.html('Importing rows...');
},
complete: function() {
status.html('Importing complete!');
}
});