<%@ 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>
检测上传文件大小
本文介绍了一个简单的HTML页面,该页面使用JavaScript函数getFileSize检测用户上传文件的大小。此功能通过在用户选择文件后立即调用该函数并在弹出窗口中显示文件大小来实现。
9750

被折叠的 条评论
为什么被折叠?



