It will be a difficult task for you to figure it out on your own. I would suggest a plugin like https://blueimp.imtqy.com/jQuery-File-Upload/
You can see from this project source code that they use a method name that basically considers how big the file is and how much data has been transferred so far, and how much percent full div remains to show.
sample code from this project
progressall: function (e, data) { var $this = $(this); $this.find('.fileupload-progress') .find('.progress').progressbar( 'option', 'value', parseInt(data.loaded / data.total * 100, 10) ).end() .find('.progress-extended').each(function () { $(this).html( ($this.data('blueimp-fileupload') || $this.data('fileupload')) ._renderExtendedProgress(data) ); }); }
https://github.com/blueimp/jQuery-File-Upload/blob/master/js/jquery.fileupload-jquery-ui.js
So, if you want to come up with your own solution, I would suggest starting with creating a rectangle div UI that has a dynamic width that is updated according to your percentage calculation based on the file upload size and the downloaded data. or just go with an already installed solution.
source share