tags:

views:

67

answers:

1

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 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.

+1  A: 

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);
   });
Tim
So you mean total size/bytes per sec = time remaining..
Abhimanyu
yeah that is possible but it's not realtime, so when the bytespersec shift the time would not change. You should do it realtime and then see how much of the file is already uploaded and how much there still needs to be done. This last variable (totalbytesuploaded or something) you have to divided by the bytespersec, that's the time remaining.
Tim