高级浏览器中,可以通过 files[0].size 获取图片的大小
<input id="image-file" type="file" name="file"/>
document.getElementById("image-file").files[0].size
浏览器支持:
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 13 | 3.0 (1.9)[1] 7 (7) | 10.0 | 11.5 | 6.0 |
参考文档:
http://www.html5rocks.com/zh/tutorials/file/dndfiles/
https://developer.mozilla.org/zh-CN/docs/Web/API/File