Progress bar on file uploading
-
Hey there,
I have a website that allow users to upload .mp3/.wav files via your form. What I need is a progress bar that returns a feedback to users, because the time spent for uploading take from 10 to 15 seconds every time.
With the VERSION 5.3.2 of the Contact Form 7 plugin, I caught (intercept) all the AJAX request and then use the eventListener “progress” to monitor the uploading remaining status. Check out the code used with 5.3.2 version:$.ajaxSetup({ xhr: function() { var xhr = new window.XMLHttpRequest(); //Upload progress xhr.upload.addEventListener( 'progress', evt => { console.log('evt', evt); if (evt.lengthComputable) { var percentComplete = evt.loaded / evt.total * 100; // Do something with upload progress if(percentComplete > 100) { percentComplete = 100; } $('.progress-bar').css('width', percentComplete+'%'); $('.progress-bar').attr('aria-valuenow', percentComplete); } }, false); return xhr; } });
From the next version, the way that CF7 send files to server is Promise (with reject and resolve) instead of $ajax request, so the code used is not valid anymore. I tried in every way to intercept the request and get the progress status of the files uploading, but I have not success. In the end…is there a way to create a progress bar with the last version of the plugin (5.5.6)? And then, how can i reach this?
I hope I was as clear as possible!
Thank you a lot!
Riccardo
- The topic ‘Progress bar on file uploading’ is closed to new replies.