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

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

问题描述

我试图搭上HTML5的浪潮,但我面临一个小问题。在HTML5之前,我们正在用闪存检查文件大小,但现在趋势是避免在网络应用程序中使用闪存。有什么方法可以在客户端使用HTML5来检查文件大小吗?

解决方案


$ b

  if(typeof FileReader!==undefined){
var size = document.getElementById('myfile')。files [0] .size;
//检查文件大小
}


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天全站免登陆