Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
335 views
in Technique[技术] by (71.8m points)

javascript - jquery file upload progress bar inaccurate

I am using jquery file upload (http://blueimp.github.io/jQuery-File-Upload/) plugin.

My Code:

$('#fileupload').fileupload({
    url: 'server/index.php',
    dataType: 'json',
    dropZone: $('#dropzone'),
}).bind('fileuploadprogress', function (e, data) {
    var progress = parseInt(data.loaded / data.total * 100, 10);
    $('.progress-bar').css('width', progress + '%');
});

When I do the file upload, the progress bar is very inaccurate. Every time when I upload no matter what size the file is, the progress bar will always stuck at around 10% until the file is upload finish, then it will directly goes up to 100%.

Why is it behave like that? How can I fix it to properly display the progress?

Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I'm having the file progress bar issue too. The odd thing is that the same implementation works on another site I have developed, but not on another. Odd as it may be, I struggled for hours trying to find out what is going on. I read another problem somewhere and blueimp here says it tested fine using similar setups, and someone mentioned that they had a proxy. Well I don't have a proxy, but then I checked it on another computer. Works fine, yet another computer, works fine again. Then I disabled AVG on my main computer, and wouldn't you know, works fine. Seems that with AVG enabled my data.loaded would almost always be the same as data.total. I'm sure it has to do with some stupid cache or something that they implement to "boost" your browsing speed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...