这个是 一个上传的asp 的代码 我想限制图片大小 50k以内
<%
Dim FormPath
FormPath = "TempUpload/" ''定义上传路径
Upload_0
Sub Upload_0()
Dim Upload
Dim File,FormName,FileName,FileExt,SaveFile
Dim CountSize,UseTime
CountSize = 0
Set Upload = Server.CreateObject("DvFile.Upload") ''建立上传对象
Upload.InceptFileType = "jpg,gif,png,bmp,jpeg" ''上传文件类型限制 以 “,” 号分隔
Upload.MaxSize = -1 ''限制大小 :-1为无限,单位 B
Upload.Install ''加载上传数据
If Upload.Err > 1 Then ''错误参数
''输出错误信息
Select Case Upload.Err
Case 1 : Response.Write Upload.Description ''请先选择你要上传的文件
Case 2 : Response.Write Upload.Description ''文件大小超过了限制 "&Upload.MaxSize/1024&"K
Case 3 : Response.Write Upload.Description ''非法的上传类型
Case 4 : Response.Write Upload.Description ''所上传的类型受系统限制
Case 5 : Response.Write Upload.Description ''参数有误,上传意外中止
End Select
Response.Write " [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
Exit Sub
Else
'If Upload.Count>1 Then Response.Write "上传个数超过限制" : Exit Sub
'FormPath = Upload.Form("filepath") ''从表单filepath获取上传路径
For Each FormName In Upload.File ''列出所有上传了的文件
Set File = Upload.File(FormName) ''生成一个文件对象
FileExt = File.FileExt ''获取上传文件后缀名
FormPath = FormatPath(FormPath) ''格式化上传路径
FileName = FormatName(FileExt) ''定义文件名
SaveFile = FormPath & FileName
If File.FileSize>0 Then ''如果 FileSize > 0 说明有文件数据
Upload.SaveToFile Server.Mappath(SaveFile),FormName ''保存文件
'Upload.FileData(FormName) ''获取单个文件内容数据
''输出信息:
Response.Write "原文件名:" & File.FileName
Response.Write "<BR>"
Response.Write "文件表单名:" & File.FormName
Response.Write "<BR>"
Response.Write "文件来源路径:" & File.FilePath
Response.Write "<BR>"
Response.Write "文件名:" & FileName
Response.Write "<BR>"
Response.Write "文件类型(File.FileType):" & File.FileType
Response.Write "<BR>"
Response.Write "文件后缀(File.FileExt):" & File.FileExt
Response.Write "<BR>"
Response.Write "图像宽(File.FileWidth):" & File.FileWidth
Response.Write "<BR>"
Response.Write "图像高(File.FileHeight):" & File.FileHeight
Response.Write "<BR>"
Response.Write "文件大小(File.FileSize):" & File.FileSize
Response.Write "<BR>"
Response.Write "保存路径:" & SaveFile
Response.Write "<BR>"
Response.Write "图片上传成功!<p>"
End If
Set File=Nothing
Next
Response.Write "共上传"& Upload.Count &"个文件 ;By "& Upload.Version &"<p>"
End If
UseTime = Upload.UseTime '总消耗时间
CountSize = Upload.TotalBytes '上传总字节数
Response.Write "总执行时间:"& UseTime &"亳秒,平均速度:"& FormatNumber(CountSize/UseTime,2,-1,0,0) &" KB/s."
Set Upload=Nothing
End Sub
Function FormatPath(Path)
FormatPath = Replace(Path,Chr(0),"")
End Function
Function FormatName(FileExt)
Dim RanNum
Randomize
RanNum = Int(90000*rnd)+10000
FormatName = Year(now)&Month(now)&Day(now)&Hour(now)&Minute(now)&Second(now)&RanNum&"."&FileExt
End Function
%>