客户端使用 HTML5 检查文件大小? [英] Client Checking file size using HTML5?

查看:27
本文介绍了客户端使用 HTML5 检查文件大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试应对 HTML5 浪潮,但我遇到了一个小问题.在 HTML5 之前,我们使用 flash 检查文件大小,但现在的趋势是避免在 web 应用程序中使用 flash.有什么办法可以使用 HTML5 在客户端检查文件大小吗?

I'm trying to ride the HTML5 wave but I'm facing a small issue. Before HTML5 we were checking the file size with flash but now the trend is to avoid using flash in web apps. Is there any way to check the file size in the client side using HTML5?

推荐答案

这有效.将其放在事件侦听器中,以便在输入更改时使用.

This works. Place it inside an event listener for when the input changes.

if (typeof FileReader !== "undefined") {
    var size = document.getElementById('myfile').files[0].size;
    // check file size
}

这篇关于客户端使用 HTML5 检查文件大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆