开发者

How to represent time base progress bar for file upload

开发者 https://www.devze.com 2023-01-18 09:54 出处:网络
Hi I am working on file upload using JavaScript+ php (basically I have used the plupload and modified it according to my need).since plupload providing the progress bar.but I need开发者_C百科 a time b

Hi I am working on file upload using JavaScript+ php (basically I have used the plupload and modified it according to my need).since plupload providing the progress bar.but I need开发者_C百科 a time based progress bar,where we can see the time remaining according to one's bandwidth and all. so I am looking for the solution for it. 1- How to implement it in general. 2- Whats the formula to calculate it.

Thanks.


I found this somewhere first part somewhere on a forum, so I didn't test it.

$("#uploader").pluploadQueue().bind("UploadProgress", function(up) {
   console.log(up.totoal.bytesPerSec); //logs the bytes per sec.
});

Maybe with the total size of the files and the bytes per sec you can calculate the time remaining.

var size = 0;
uploader.bind('FilesAdded', function(up, files) {
   $each(files, function(file, i) {
     size += (file.size);
   });


To achieve this with plupload you can compute this:

console.log((up.total.size-up.total.loaded)/up.total.bytesPerSec)

Do this during the UploadProgress event binding.

0

精彩评论

暂无评论...
验证码 换一张
取 消