jQuery-File-Upload progress

137 Views Asked by At

I'm using the jquery file upload plugin (https://blueimp.github.io/jQuery-File-Upload/). This one is working pretty well when testing the demo on my own server, however, I would like to use it in a different way.

Instead of using the progressall function, and the classic submit function, I do use it this way:

var url = "http://localhost:8080/upload"
$('#fileupload').fileupload({
    url: url,
    forceIframeTransport: false,
    add: function (e, data) {
        $("#container").data("data2upload", data);
    }
})
$("#upbtn").click(function(){
    $("#cont").data("data2upload").submit();
});

it allows me to add as many file I want and to synch the upload on a click. When I want to display the progress, I do like this:

var tloaded = $('#fileupload').fileupload('progress').loaded,
    t2load  = $('#fileupload').fileupload('progress').total;

however, the value of the loaded is 0 until the end where it comes to t2load. What is enoying for the final user. (I'm not cross-domain). What am I doing wrong ?

thanks, Jerome

1

There are 1 best solutions below

0
On

Can you use something like what I have below (from the DOCs)?

var url = "http://localhost:8080/upload",
progress = 0;

$('#fileupload').fileupload({
    url: url,
    forceIframeTransport: false,
    progress: function (e, data) {
         progress = parseInt(data.loaded / data.total * 100, 10);
    },
    add: function (e, data) {
        $("#container").data("data2upload", data);
    }
})
$("#upbtn").click(function(){
    $("#cont").data("data2upload").submit();
});

Note the progress method above