⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 saveannouce_upfile.asp

📁 网上商城的源码
💻 ASP
字号:
<!--#include FILE="conn.asp"-->
<!--#include FILE="upload.inc"-->
<!-- #include file="inc/const.asp" -->

<html>
<head>
<title>文件上传</title>
<!--#include file="inc/Forum_css.asp"-->
</head>
<body <%=Forum_body(11)%>>

<script>
parent.document.forms[0].Submit.disabled=false;
parent.document.forms[0].Submit2.disabled=false;
</script>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class=tablebody1 valign=top height=40>
<%
Server.ScriptTimeOut=999999'要是你的论坛支持上传的文件比较大,就必须设置。
'上传方法,0=无组件,1=lyfupload,2=aspupload,3=chinaaspupload
dim upload_type
upload_type=0
dim upload,file,formName,formPath,iCount,filename,fileExt
dim upNum
dim uploadsuc
dim Forumupload
dim ranNum,fs
dim uploadfiletype
dim rename,DownloadID
upNum=request.cookies("upNum")
if upnum ="" then upnum=0
upNum=int(upNum)
if Cint(GroupSetting(7))=0 then
	response.write "您没有在本论坛上传文件的权限"
	response.end
end if
if not founduser then
 	response.write "只有登陆用户方能上传!"
	response.end
end if
if upNum >= int(GroupSetting(40)) then
 	response.write "一次只能上传"&GroupSetting(40)&"个文件!"
	response.end
end if

Forumupload=split(Board_Setting(19),"|")

select case upload_type
case 0
	call upload_0()
case 1
	call upload_1()
case else
	response.write "本系统未开放插件功能"
	response.end
end select

sub upload_0()
set upload=new upload_5xSoft ''建立上传对象

formPath=upload.form("filepath")
'在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/" 
for each formName in upload.file ''列出所有上传了的文件
	set file=upload.file(formName)  ''生成一个文件对象
	if file.filesize < 50 then
 	response.write "请先选择你要上传的文件 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
	response.end
	end if

	if file.filesize> int(GroupSetting(44))*1024 then
 	response.write "文件大小超过了限制 "&Forum_Setting(33)&"K [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
	response.end
	end if
	
	uploadsuc=false
	dim fileExt_a
	fileExt_a=split(file.filename,".")
	fileExt=lcase(fileExt_a(ubound(fileExt_a)))
	Forumupload=split(Board_Setting(19),"|")
	for i=0 to ubound(Forumupload)
		if lcase(fileEXT)=lcase(trim(Forumupload(i))) then
			uploadsuc=true
			exit for
		else
			uploadsuc=false
		end if
	next
	if fileEXT="asp" and fileEXT="asa" and fileEXT="aspx" then
		uploadsuc=false
	end if
	if uploadsuc=false then
 	response.write "文件格式不正确 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
	response.end
	end if

	filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
	rename=filename&"|"
	filename=formPath&filename
	'判断文件类型
	dim F_Type
	if lcase(fileExt)="gif" or lcase(fileExt)="jpg" or lcase(fileExt)="jpeg" or lcase(fileExt)="bmp" or lcase(fileExt)="png" then
	F_Type=1
	elseif lcase(fileExt)="swf" or lcase(fileExt)="swi" then
	F_Type=2
	elseif lcase(fileExt)="mid" or lcase(fileExt)="wav" or lcase(fileExt)="mp3" or lcase(fileExt)="rmi" or lcase(fileExt)="cda" then
	F_Type=3
	elseif lcase(fileExt)="avi" or lcase(fileExt)="wov" or lcase(fileExt)="asf" or lcase(fileExt)="mpg" or lcase(fileExt)="mpeg" or lcase(fileExt)="ra" or lcase(fileExt)="ram" then
	F_Type=4
	else
	F_Type=0
	end if

	'插入上传表并获得ID
	conn.execute("insert into dv_upfile (F_BoardID,F_UserID,F_Username,F_Filename,F_FileType,F_Type,F_FileSize) values ("&BoardID&","&UserID&",'"&membername&"','"&replace(rename,"|","")&"','"&replace(fileExt,".","")&"',"&F_Type&","&file.FileSize&")")
	set rs=conn.execute("select top 1 F_ID from dv_upfile order by F_ID desc")
	DownloadID=rs(0)
	rename=DownloadID & ","
	if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据
	file.SaveAs Server.mappath(FileName)   ''保存文件
	for i=0 to ubound(Forumupload)
		if lcase(fileEXT)=lcase(trim(Forumupload(i))) then
		if F_Type=1 then
	 	response.write "<script>parent.frmAnnounce.Content.value+='[upload="&Forumupload(i)&"]"&filename&"[/upload]'</script>"
		else
	 	response.write "<script>parent.frmAnnounce.Content.value+='[upload="&Forumupload(i)&"]viewfile.asp?ID="&DownloadID&"[/upload]'</script>"
		end if
		response.write "<script>parent.frmAnnounce.upfilerename.value+='"&rename&"'</script>"
		exit for
		end if
	next
	upNum=upNum+1
	response.cookies("upNum")=upNum
	end if
	set file=nothing
next
set upload=nothing

if upNum < int(GroupSetting(40)) then
	response.write upNum&"个文件上传成功 [ <a href=# onclick=history.go(-1)>继续上传</a> ]"
else
	response.write upNum&"个文件上传成功!本次已达到上传数上限。"
end if
end sub


'lyfupload
sub upload_1()
dim obj,filepath,filename,fs,fileExt
dim fileExt_a
dim ss,aa1,aa
Set obj = Server.CreateObject("LyfUpload.UploadFile")
'大小
obj.maxsize=int(GroupSetting(44))*1024
'类型
obj.extname=replace(Board_Setting(19),"|",",")
'重命名

formPath=obj.request("filepath")
'在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/" 
filepath=Server.MapPath(formPath)
fileExt_a=split(obj.request("fname"),".")
fileExt=lcase(fileExt_a(ubound(fileExt_a)))
filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
rename=filename & "|"

'response.write filename
'response.end

ss=obj.SaveFile("file1",filepath, true,filename)
if ss= "3" then
	Response.Write ("文件名重复! [ <a href=# onclick=history.go(-1)>重新上传</a> ]")
	response.end
elseif ss= "0" then
	Response.Write ("文件尺寸过大! [ <a href=# onclick=history.go(-1)>重新上传</a> ]")
	response.end
elseif ss = "1" then
	Response.Write ("文件不是指定类型文件! [ <a href=# onclick=history.go(-1)>重新上传</a> ]")
	response.end
elseif ss = "" then
	Response.Write ("文件上传失败! [ <a href=# onclick=history.go(-1)>重新上传</a> ]")
	response.end
else
'判断文件类型
	dim F_Type
	if lcase(fileExt)="gif" or lcase(fileExt)="jpg" or lcase(fileExt)="jpeg" or lcase(fileExt)="bmp" or lcase(fileExt)="png" then
	F_Type=1
	elseif lcase(fileExt)="swf" or lcase(fileExt)="swi" then
	F_Type=2
	elseif lcase(fileExt)="mid" or lcase(fileExt)="wav" or lcase(fileExt)="mp3" or lcase(fileExt)="rmi" or lcase(fileExt)="cda" then
	F_Type=3
	elseif lcase(fileExt)="avi" or lcase(fileExt)="wov" or lcase(fileExt)="asf" or lcase(fileExt)="mpg" or lcase(fileExt)="mpeg" or lcase(fileExt)="ra" or lcase(fileExt)="ram" then
	F_Type=4
	else
	F_Type=0
	end if

	upNum =upNum +1
	'插入上传表并获得ID
	conn.execute("insert into dv_upfile (F_BoardID,F_UserID,F_Username,F_Filename,F_FileType,F_FileSize,F_Type) values ("&BoardID&","&UserID&",'"&membername&"','"&filename&"','"&fileExt&"',"&obj.filesize&","&F_Type&")")
	set rs=conn.execute("select top 1 F_ID from dv_upfile order by F_ID desc")
	DownloadID=rs(0)
	rename=DownloadID & ","
	
	 for i=0 to ubound(Forumupload)
		if lcase(fileEXT)=lcase(trim(Forumupload(i))) then
		if F_Type=1 then
	 	response.write "<script>parent.frmAnnounce.Content.value+='[upload="&Forumupload(i)&"]"&formPath&filename&"[/upload]'</script>"
		else
	 	response.write "<script>parent.frmAnnounce.Content.value+='[upload="&Forumupload(i)&"]viewfile.asp?ID="&DownloadID&"[/upload]'</script>"
		end if
		response.write "<script>parent.frmAnnounce.upfilerename.value+='"&rename&"'</script>"
		exit for
		end if
	next

	if upNum  < clng(GroupSetting(40)) then
		response.write upNum&"文件上传成功 [ <a href=# onclick=history.go(-1)>继续上传</a> ]"
	else
		response.write upNum&"文件上传成功 ,本次已经达到上传上限。"
	end if
	
	response.cookies("upNum")=upNum
end if
set obj=nothing
end sub

%>
</td></tr>
</table>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -