вот примерный код
<form id="verFileForm" enctype="multipart/form-data" action="uploadVersion" method="POST">
<input type="file" name="versionFile">
<input type="number" name="appId" th:value="${appid}" style="display: none">
<input type="number" name="versionId" th:value="${version.getId()}" style="display: none">
</form>
$.ajax({
url : post_url,
type: request_method,
data : form_data,
contentType: false,
cache: false,
processData:false,
xhr: function() {
var xhr = $.ajaxSettings.xhr();
xhr.upload.onprogress = function(e) {
jQuery('#progress').attr("style","");
jQuery('#progress-bar').css("width",e.loaded /
e.total *100 + "%");
jQuery('#progress-bar').html(Math.ceil(e.loaded /
e.total *100) + "%");
console.log(Math.floor(e.loaded /
e.total *100) + '%');
};
return xhr;
},
success: function(data){
// делать что-то при успешном завершении...
doneFunction(data);
jQuery('#progress').attr("style","display: none");
}
});