/ Published in: JavaScript

I use this in addition to the
number_format (http://snipplr.com/view/5945/javascript-numberformat--ported-from-php/)
snippit in SWFUpload to display the size of files a user is preparing to upload.
number_format (http://snipplr.com/view/5945/javascript-numberformat--ported-from-php/)
snippit in SWFUpload to display the size of files a user is preparing to upload.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function size_format (filesize) { if (filesize >= 1073741824) { filesize = number_format(filesize / 1073741824, 2, '.', '') + ' Gb'; } else { if (filesize >= 1048576) { filesize = number_format(filesize / 1048576, 2, '.', '') + ' Mb'; } else { if (filesize >= 1024) { filesize = number_format(filesize / 1024, 0) + ' Kb'; } else { filesize = number_format(filesize, 0) + ' bytes'; }; }; }; return filesize; };
Comments
