📄 upfile.asp
字号:
<!--#include file="../inc/function.asp"-->
<!--#include file="../inc/ChkPurview.asp"-->
<!--#include file="upfile_class.asp"-->
<%
if GetUserGPower<>9999 then
Call Msg("您没有访问权限",1,"")
end if
Dim strJS
const upload_type=0 '上传方法:0=无惧无组件上传类,1=FSO上传 2=lyfupload,3=aspupload,4=chinaaspupload
dim upload,oFile,formName,SavePath,filename,fileExt,filename1
dim ImgWidth,ImgHeight
dim EnableUpload
dim arrUpFileType
dim ranNum
dim msg1,FoundErr
msg1=""
Dim MaxFileSize,UpFileType
MaxFileSize = 1200
FoundErr=false
EnableUpload=false
UpFileType="gif|jpg|"
SavePath = "../pic/" '存放上传文件的目录
if right(SavePath,1)<>"/" then SavePath=SavePath&"/" '在目录后加(/)
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0">
<%
select case upload_type
case 0
call upload_0() '使用化境无组件上传类
case else
'response.write "本系统未开放插件功能"
'response.end
end select
' end if
%>
</body>
</html>
<%
sub upload_0() '使用化境无组件上传类
set upload=new upfile_class ''建立上传对象
upload.GetData(104857600) '取得上传数据,限制最大上传100M
if upload.err > 0 then '如果出错
select case upload.err
case 1
response.write "请先选择你要上传的文件!"
case 2
response.write "你上传的文件总大小超出了最大限制(100M)"
end select
response.end
end if
for each formName in upload.file '列出所有上传了的文件
set ofile=upload.file(formName) '生成一个文件对象
if ofile.filesize<100 then
msg1="请先选择你要上传的文件!"
FoundErr=True
end if
if ofile.filesize>(MaxFileSize*1024) then
msg1="文件大小超过了限制,最大只能上传" & CStr(MaxFileSize) & "K的文件!"
FoundErr=true
end if
fileExt=lcase(ofile.FileExt)
arrUpFileType=split(UpFileType,"|")
for i=0 to ubound(arrUpFileType)
if fileEXT=trim(arrUpFileType(i)) then
EnableUpload=true
exit for
end if
next
if fileEXT="asp" or fileEXT="asa" or fileEXT="aspx" then
EnableUpload=false
end if
if EnableUpload=false then
msg1="这种文件类型不允许上传!\n\n只允许上传这几种文件类型:" & UpFileType
FoundErr=true
end if
strJS="<SCRIPT language=javascript>" & vbcrlf
if FoundErr<>true then
randomize
ranNum=int(900*rnd)+100
FileName=SavePath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
' Response.Write Server.mappath(FileName)
' Response.end
ofile.SaveToFile Server.mappath(FileName) '保存文件FileName
msg1="上传文件成功!"
strJS=strJS & "parent.form1.Pro_TP.value='" &FileName& "';" & vbcrlf
end if
strJS=strJS & "alert('" & msg1 & "');" & vbcrlf
strJS=strJS & "history.go(-1);" & vbcrlf
strJS=strJS & "</script>"
response.write strJS
set file=nothing
next
set upload=nothing
end sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -