Posted By

mariraj on 07/12/11


Tagged


Versions (?)

Find file size


 / Published in: jQuery
 

Find file size in clinet side

  1. <input type="file" id="loadfile" />
  2. <input type="button" value="find size" onclick="findSize()" />
  3. <script type="text/javascript">
  4. function findSize()
  5. {
  6. var fileInput = $("#loadfile")[0];
  7. byteSize = fileInput.files[0].fileSize;
  8. var suffix = 'KB';
  9. if (byteSize > 1000) {
  10. byteSize = Math.round(byteSize *.001 * 100) * .01;
  11. suffix = 'MB';
  12. }
  13.  
  14. alert( byteSize + '-' + suffix); // Size returned in bytes.
  15. }
  16. </script>

Report this snippet  

You need to login to post a comment.