浏览器读取上传文件的大小 file api

来源:互联网 发布:js读取手机本地文件 编辑:程序博客网 时间:2024/05/19 18:11


高级浏览器中,可以通过  files[0].size  获取图片的大小

 <input id="image-file" type="file" name="file"/>

document.getElementById("image-file").files[0].size
 

浏览器支持:


  • Desktop 
  • Mobile
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)Basic support133.0 (1.9)[1]
7 (7)10.011.56.0

参考文档:


http://www.html5rocks.com/zh/tutorials/file/dndfiles/

https://developer.mozilla.org/zh-CN/docs/Web/API/File

0 0