‘檢查文件類(lèi)型函數(shù)
Private CheckFileExt (fileEXT)
dim filetype
filetype="asp,asa,aspx"
filetype=split(filetype,",")
for i=0 to ubound(filetype)
if lcase(fileEXT)=lcase(trim(filetype(i))) then
CheckFileExt=false
exit
else
CheckFileExt=true
end if
next
End
'上傳函數(shù)
sub upload_2()
dim Count
on error resume next
Set Upload = Server.CreateObject("Persits.Upload")
Upload.OverwriteFiles = false '不允許覆蓋重名文件
Upload.IgnoreNoPost = True
Upload.SetMaxSize 1048576, True '文件大小限制
Count = Upload.Save
If Err.Number = 8 Then
Response.Write "文件太大,請(qǐng)壓縮后再上傳(文件大小不得超過(guò)10M) [ <a href=# =history.go(-1)>重新上傳</a> ]"
Else
If Err <> 0 Then
Response.Write "錯(cuò)誤信息: " & Err.Deion
Else
If Count < 1 Then
Response.Write "請(qǐng)首先選擇你要上傳的文件 [ <a href=# =history.go(-1)>重新上傳</a> ]"
set Upload =nothing
exit sub
End If
For Each file in Upload.Files '列出所有上傳文件
fileExt=lcase(replace(File.ext,".",""))
'判斷文件類(lèi)型
if CheckFileExt(fileEXT)=false then
set upload = nothing
response.write "禁止上傳asp和asa文件 [ <a href=# =history.go(-1)>重新上傳</a> ]"
exit sub
end if
'文件變量付值
randomize
ranNum=int(90000*rnd)+10000
filename=user&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&File.ext
downname="userfiles/"&filename
filename="../userfiles/"&filename
file.saveas Server.MapPath(filename) '上傳保存文件
response.write "文件已成功上傳"
response.write filesm
'response.write "請(qǐng)復(fù)制軟件地址到下載地址處:"
'response.write "<input type=text name=T1 size=50 value="&downname&">"
Next
End If
End If
set Upload = nothing
end sub