Calculate progress bar percentage

Nic Hubbard picture Nic Hubbard · Aug 23, 2009 · Viewed 12.3k times · Source

I am building a file upload progress bar. Currently I have an upload form which returns the current amount of uploaded data. So, it starts at zero, and returns the current size in bits, but I have converted that to bytes.

If I can get the total file size before I upload, and can get the current amount uploaded, and return this dynamically, how could I calculate this so that I can use a 1-100% value for a css width?

I am using the swfupload jquery plugin: http://blogs.bigfish.tv/adam/2009/06/14/swfupload-jquery-plugin

Answer

Atmocreations picture Atmocreations · Aug 23, 2009

Percents uploaded=100/file size*bytes uploaded

remember to use the same units for both sizes.

Regards