怎么在ASP上传页面加上传文件大小判断

来源:百度知道 编辑:UC知道 时间:2024/05/27 06:06:37
我的源代码如下,请问怎么加判断来设定文件大小限制?
<%
Response.Buffer = True
Server.ScriptTimeOut=999
On Error Resume Next
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>网站后台文件上传</title>
<script>
function viewmypic(mypic,imgfile) {
if (imgfile.value){
mypic.src=imgfile.value;
mypic.style.display="";
mypic.border=1;
}
}
</script>
</head>
<body id="body">
<%
ExtName = "jpg,gif,bmp,png,swf,wma,mp3,rm,mid,rar" '允许扩展名
SavePath = "upload/" '保存路径
If Right(SavePath,1)<>"/" Then SavePath=SavePath&"/" '在目录后加(/)
CheckAndCreateFolder(SavePath)

UpLoadAll_a = Request.TotalBytes '取得客户端全部内容
If(UpLoadAll_a>0) Then
Set UploadStream_c = Server.CreateObject(&

你好,针对你的代码,我修改了一下,你可以用Request.TotalBytes来获取上传文件的大小,具体代码如下:

<%
Response.Buffer = True
Server.ScriptTimeOut=102400
On Error Resume Next
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="Content-Language" content="zh-cn" />
<meta content="all" name="robots" />
<style type="text/css">
<!--
body,input {
font-size:12px;
color: #000000;
font-style: normal;
line-height: 16px;
text-decoration: none;
}
.bt {
font-size:14px;
color: #FF0000;
font-style: normal;
line-height: 18px;
text-decoration: none;
}
-->
</style>
<title>网站后台文件上传</title>
<script>
function viewmypic(mypic,imgfile) {
if (imgfile.value){
mypic.src=imgfile.value;<