Browser front-end JS to determine the upload file size (Ie8,ff6,chrome17 can be measured)

Source: Internet
Author: User

Looked at the various stickers, and finally found a JS, seemingly can be used to judge the last file size of the method, but also do not need to adjust the security level, and what components.

  1. <script type="Text/javascript" >
  2. function GetFileSize (fileobj)
  3. {
  4. //cannot use the new Image,ie to report no Dynsrc property
  5. var img1 = document.getElementById (' img1 ');
  6. Img1.dynsrc=fileobj.value;
  7. //img1.filesize:ie, Fileobj.files[0].filesize:chrome, Fileobj.files[0].size:ff
  8. var size = Img1.filesize | |    fileobj.files[0].filesize | | fileobj.files[0].size;
  9. alert (size);
  10. }
  11. </script>
  12. <body>
  13. <input type="file" name="file" size="" Onchange= "getfilesize (This)" >
  14. ' img1 ' dynsrc='/>
  15. </body>

Browser front-end JS to determine the upload file size (Ie8,ff6,chrome17 can be measured)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.