六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 99|回复: 0

JavaScript获取上传文件大小

[复制链接]

升级  36%

4

主题

4

主题

4

主题

童生

Rank: 1

积分
18
 楼主| 发表于 2013-2-7 19:54:36 | 显示全部楼层 |阅读模式
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"><html> <head>  <title> new document </title>  <meta name="generator" content="editplus">  <meta name="author" content="">  <meta name="keywords" content="">  <meta name="description" content=""> </head><script type="text/javascript">    function getFileSize(filePath)    {       var image=new Image();       image.dynsrc=filePath;       alert(image.fileSize);    }    </script>    <body>    <INPUT TYPE="file" NAME="file" SIZE="30" onchange="getFileSize(this)">    </body> <script type="text/javascript">function getFileSize(fileObj){   var image=new Image();   image.dynsrc=fileObj.value;   var size = image.fileSize || fileObj.files[0].fileSize;   if(size > 100000){alert(size);   }   }</script><body><INPUT TYPE="file" NAME="file" SIZE="30" onchange="getFileSize(this.value)"></body></html> 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表