I have a javascript function that is displaying picture preview and uploading it automatically on onchange event (this part is working).
I would like to add progress bar. After searching here all I can find are solutions working with submit button. File upload progress bar with jQuery
Can you please help me modify the code
Thanks
<input type="file" id="5_slika_upload" name="5_pocetna_slika_file" accept="image/*" />
function pocetna_slika_upload_select(){
pocetna_slika_upload_div.style.display="flex";
var reader = new FileReader();
reader.onload = function() {
var output = pocetna_slika_upload_div_img;
output.src = reader.result;
}
reader.readAsDataURL(event.target.files[0]);
var file_data = $('#5_slika_upload').prop('files')[0];
var form_data = new FormData();
form_data.append('file', file_data);
$.ajax({
url: "https://markolucic.from.hr/image_upload.php",
type: "POST",
data: form_data,
contentType: false,
cache: false,
processData:false,
success: function(data){
console.log(data);
}
});
//add code for progress bar :)
}