求翻译 ASP 上传文件
<%'on error resume next
Server.ScriptTimeOut=999999'要是你的论坛支持上传的文件比较大,就必须设置。
dim upload_type
dim formPath2
upload_type=0
'定义变量
dim Forumupload,ranNum
dim formName,formPath,filename,file_name,fileExt,Filesize,F_Type
dim upNum,dateupnum
dim rename,DownloadID
dim isspic
select case upload_type
case 0
call upload_0()
case 1
call upload_1()
case 2
call upload_2()
case else
response.write "本系统未开放插件功能"
response.end
end select
'===========================无组件上传============================
sub upload_0()
dim upload,file
set upload=new UpFile_Class ''建立上传对象
upload.GetData(int(GetOneSet(7))*1024) '取得上传数据,不限大小
if upload.err > 0 then
select case upload.err
case 1
Response.Write "请先选择你要上传的文件 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
case 2
Response.Write "文件大小超过了限制 "&GetOneSet(7)&"K [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
end select
exit sub
else
isspic=upload.Form("hdnISSPic")
formPath=upload.form("filepath")
formPath2=formPath
if checkfso() then
if not CheckDir(formPath2) then
MakeNewsDir(formPath2)
end if
end if
'在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/"
for each formName in upload.file ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
fileExt=lcase(file.FileExt)
'判断文件类型
if lcase(fileEXT)="asp" and lcase(fileEXT)="asa" and lcase(fileEXT)="aspx" then
CheckFileExt(fileEXT)=false
end if
if CheckFileExt(fileEXT)=false then
response.write "文件格式不正确 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
response.end
end if
'付值变量
randomize
ranNum=int(90000*rnd)+10000
F_Type=CheckFiletype(fileEXT)
file_name=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum
filename=file_name&"."&fileExt
rename=filename&"|"
filename=formPath&filename
Filesize=file.FileSize
'记录文件
if Filesize>0 then '如果 FileSize > 0 说明有文件数据
file.SaveToFile Server.mappath(FileName) ''执行上传文件
'创建生成预览图片
'略……
call checksave() '记录文件
end if
set file=nothing
next
end if
set upload=nothing
'response.write "文件上传成功 [ <a href=# onclick=history.go(-1)>继续上传</a> ]"
response.write "[文件上传成功]"
end sub
Private sub checksave()
'插入上传表并获得ID
'conn.execute("insert into P_propic(UserID,Username,PicName,PicType,Type,PicSize,addTime) values ("&session("managerId")&",'"&session("manager")&"','"&formPath&replace(rename,"|","")&"','"&replace(fileExt,".","")&"',"&F_Type&","&Filesize&",'"&now()&"')")
'set rs=conn.execute("select top 1 ID from P_propic order by ID desc")
' DownloadID=rs(0)
'rename=DownloadID & ","
' set rs=nothing
if isspic="1" then
response.write "<script>parent.form1.hdnSPicName.value='"&filename&"'</script>"
else
response.write "<script>parent.form1.hdnPicName.value='"&filename&"'</script>"
end if
'response.Write "<script>this.parent.transferContent();</ script>"
'if F_Type=1 then
'response.write "<script>parent.form1.content.value+='<img src="&filename&">'</ script>"
'else
'response.write "<script>parent.form1.content.value+='<img src=../images/files/"&fileExt&".gif> <a href=downfile.asp?ID="&DownloadID&">相关附件</a>'</ script>"
'end if
'response.Write "<script>this.parent.LoadContent();</ script>"
'response.write "<script>parent.form1.upfilerename.value+='"&rename&"'</ script>"
end sub
Private Function CheckFileExt(fileEXT)
dim Forumupload
Forumupload=split(GetOneSet(8),"|")
for i=0 to ubound(Forumupload)
if lcase(fileEXT)=lcase(trim(Forumupload(i))) then
CheckFileExt=true
exit Function
else
CheckFileExt=false
end if
next
End Function
Private Function CheckFiletype(fileEXT)
dim upFiletype
dim FilePic,FileVedio,FileSoft,FileFlash,FileMusic
fileEXT=lcase(replace(fileExt,".",""))
FilePic=".gif.jpg.jpeg.png.bmp.tif.iff"
upFiletype=split(FilePic,".")
for i=0 to ubound(upFiletype)
if fileEXT=lcase(trim(upFiletype(i))) then
CheckFiletype=1
exit Function
end if
next
FileFlash=".swf.swi"
upFiletype=split(FileFlash,".")
for i=0 to ubound(upFiletype)
if fileEXT=lcase(trim(upFiletype(i))) then
CheckFiletype=2
exit Function
end if
next
FileMusic=".mid.wav.mp3.rmi.cda"
upFiletype=split(FileMusic,".")
for i=0 to ubound(upFiletype)
if fileEXT=lcase(trim(upFiletype(i))) then
CheckFiletype=3
exit Function
end if
next
FileVedio=".avi.mpg.mpeg.ra.ram.wov.asf"
upFiletype=split(FileVedio,".")
for i=0 to ubound(upFiletype)
if fileEXT=lcase(trim(upFiletype(i))) then
CheckFiletype=4
exit Function
end if
next
FileSoft=".rar.zip.exe.php.php3.asp.aspx.htm.html.shtml.js.jsp.pdf.inc.doc.txt.chm.hlp"
CheckFiletype=0
end function
conn.close
set conn=nothing
%>
最好是一句一句翻译下 谢谢