js检测上传文件的大小

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>检测上传文件的大小</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
function getFileSize(filePath)
{
var image=new Image();
image.dynsrc=filePath;

alert(image.fileSize); //不是图片文件也能检测其大小

}



</script>
</head>

<body>

<form action="" name="form1" method="post" enctype="multipart/form-data">
<INPUT TYPE="file" NAME="pic" SIZE="30" onchange="getFileSize(this.value)">
<input type="submit" name="smt" value="确定">
</form>

</body>
</html>

你可能感兴趣的:(JavaScript,html,css,cache)