upfile.asp

来自「1. 硬件环境:MS WINDOWS NT PACK 4 OR LATER /W」· ASP 代码 · 共 179 行

ASP
179
字号
<!-- #include file="setup.asp" -->
<!--#include FILE="inc/upfile.asp"-->
<!--#include FILE="inc/function.asp"-->
<%
validate "Login.asp",0
cluburl="http://"&Request.ServerVariables("server_name")&replace(Request.ServerVariables("path_info"), "upfile.asp", "")
if Request("menu")="up" then

formPath=Request("formPath")
	On Error Resume Next
	Set upl = Server.CreateObject("SoftArtisans.FileUp")
	If -2147221005 = Err Then
	''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
		set FileUP=new Upload_file 
		FileUP.GetDate(-1)
		formPath=FileUP.form("formPath")
		set file=FileUP.file("file")
		FaceName=month(now)&day(now)&hour(now)&minute(now)&second(now)
		ThisName=FaceName&"."&file.FileExt
		filename=formPath&ThisName
		
		Select Case formPath
		Case "images/upfile/"
			if file.filesize > 102400 then error 2,"文件大小不得超过 100 K\n当前的文件大小为 "&int(file.filesize/1024)&" K",""
		Case "images/upphoto/"
			if LCase(file.FileExt) <> "gif" and LCase(file.FileExt) <> "jpg" Then 	Error 2,"对不起,本服务器只支持GIF、JPG格式的照片上传\n不支持 "&LCase(file.FileExt)&" 格式的文件",""
			if file.filesize > 30720 then error 2,"文件大小不得超过 30 K\n当前的文件大小为 "&int(file.filesize/1024)&" K",""
		Case "images/face/"
			if LCase(file.FileExt) <> "gif" Then Error 2,"对不起,本服务器只支持GIF格式的头像上传\n不支持 "&LCase(file.FileExt)&" 格式的文件",""
			if file.filesize > 10240 then error 2,"头像大小不得超过 10 K\n当前的文件大小为 "&int(file.filesize/1024)&" K",""
		Case Else
			Error 1,"参数非法传递!\n您的IP已被记录!",""
		End Select
			
		
		select case LCase(file.FileExt)
		case "gif"
		img="[img]"&cluburl&filename&"[/img]"
		case "jpg"
		img="[img]"&cluburl&filename&"[/img]"
		case "swf"
		img="[flash]"&cluburl&filename&"[/flash]"
		case "htm"
		img="[img]"&cluburl&"/images/affix.gif[/img][url="&cluburl&filename&"]相关附件[/url]"
		case "txt"
		img="[img]"&cluburl&"/images/affix.gif[/img][url="&cluburl&filename&"]相关附件[/url]"
		case "doc"
		img="[img]"&cluburl&"/images/affix.gif[/img][url="&cluburl&filename&"]相关附件[/url]"
		case "zip"
		img="[img]"&cluburl&"/images/affix.gif[/img][url="&cluburl&filename&"]相关附件[/url]"
		case "zip"
		img="[img]"&cluburl&"/images/affix.gif[/img][url="&cluburl&filename&"]相关附件[/url]"
		case else
		Error 2,"对不起,本服务器只支持GIF、JPG、HTM、TXT、DOC、ZIP、SWF格式的文件\n不支持 "&file.FileExt&" 格式的文件",""
		end select
		
		if file.filesize=Request.Cookies("TotalBytes") then	Error 2,"请不要上传相同的文件!",""

		
		file.SaveToFile Server.mappath(filename)
		Response.Cookies("TotalBytes")=file.filesize
		set FileUP=nothing
	''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	else
	
	
	Select Case Request("m")
	Case "UpFile"
	formPath="images/upfile/"
		if upl.TotalBytes > 102400 then	error 2,"文件大小不得超过 100 K\n当前的文件大小为 "&int(upl.TotalBytes/1024)&" K",""
	Case "UpPhoto"
	formPath="images/upphoto/"
		if upl.TotalBytes > 30720 then	error 2,"照片大小不得超过 30 K\n当前的文件大小为 "&int(upl.TotalBytes/1024)&" K",""
	Case "UpFace"
	formPath="images/face/"
		if upl.TotalBytes > 10240 then	error 2,"头像大小不得超过 10 K\n当前的文件大小为 "&int(upl.TotalBytes/1024)&" K",""
	Case Else
		Error 1,"参数非法传递!\n您的IP已被记录!",""
	End Select

	
		filename=month(date)&day(date)&hour(time)&minute(time)&second(time)
		Tfilename=filename
		select case ""&upl.ContentType&""
		case "application/octet-stream"
			error 2,"未知文件格式",""
		case "image/gif"
			types="gif"
			filename=formPath&filename&"."&types
			img="[img]"&cluburl&"/"&filename&"[/img]"
		case "image/pjpeg"
			types="jpg"
			filename=formPath&filename&"."&types
			img="[img]"&cluburl&"/"&filename&"[/img]"
		case "text/html"
			types="htm"
			filename=formPath&filename&"."&types
			img="[img]"&cluburl&"/images/affix.gif[/img][url="&cluburl&"/"&filename&"]相关附件[/url]"
		case "text/plain"
			types="txt"
			filename=formPath&filename&"."&types
			img="[img]"&cluburl&"/images/affix.gif[/img][url="&cluburl&"/"&filename&"]相关附件[/url]"
		case "application/msword"
			types="doc"
			filename=formPath&filename&"."&types
			img="[img]"&cluburl&"/images/affix.gif[/img][url="&cluburl&"/"&filename&"]相关附件[/url]"
		case "application/x-zip-compressed"
			types="zip"
			filename=formPath&filename&"."&types
			img="[img]"&cluburl&"/images/affix.gif[/img][url="&cluburl&"/"&filename&"]相关附件[/url]"
		case "application/x-shockwave-flash"
			types="swf"
			filename=formPath&filename&"."&types
			img="[flash]"&cluburl&"/"&filename&"[/flash]"
		case else
		error 2,"对不起,本服务器只支持GIF、JPG、HTM、TXT、DOC、ZIP、SWF格式的文件\n不支持 "&file.FileExt&" 格式的文件",""
		end select
		
		if instr(formPath,"images/upphoto") > 0 Then ThisName=Tfilename&"."&types : if types <> "gif" and types <> "jpg" Then 	Error 2,"对不起,本服务器只支持GIF、JPG格式的照片上传\n不支持 "&file.FileExt&" 格式的文件",""
		
		if instr(formPath,"images/face/") > 0 Then FaceName=Tfilename : if types <> "gif" Then 	Error 2,"对不起,本服务器只支持GIF格式的头像上传\n不支持 "&file.FileExt&" 格式的文件",""
	
		if upl.TotalBytes=Request.Cookies("TotalBytes") then error 2,"请不要上传相同的文件!",""
		upl.SaveAs Server.mappath(filename)
		Response.Cookies("TotalBytes")=upl.TotalBytes
		set upl=nothing
	End If
	
	Select Case formPath
	Case "images/upfile/"
	response.write "<body topmargin=0 bgcolor=#BFD3EE><link href=css.css rel=stylesheet><body topmargin=1><SCRIPT>parent.form.content.value+='"&img&"'</SCRIPT>"
	response.write "<a target=_blank href=http://"&Request.ServerVariables("server_name")&replace(Request.ServerVariables("path_info"), "upfile.asp", "")&filename&">http://"&Request.ServerVariables("server_name")&replace(Request.ServerVariables("path_info"), "upfile.asp", "")&filename&"</a>"
	Case "images/upphoto/"
		if Conn.execute("Select UserPhoto from UserInfo where UserID="&Request.Cookies("User"))(0) <> ".jpg" Then DelFile "images/upphoto/",Conn.execute("Select UserPhoto from UserInfo where UserID="&Request.Cookies("User"))(0)
	conn.execute("Update UserInfo set UserPhoto='"&ThisName&"' where UserID="&Request.Cookies("User"))
	response.write "<body topmargin=0 ><link href=css.css rel=stylesheet><body topmargin=1>"
	response.write "<a target=_blank href=http://"&Request.ServerVariables("server_name")&replace(Request.ServerVariables("path_info"), "upfile.asp", "")&filename&">照片上传成功,请点击查看或按刷新按钮!</a>"
	Case "images/face/"

		if int(Conn.execute("Select UserHead from UserInfo where UserID="&Request.Cookies("User"))(0)) > 180 Then DelFile "images/face/",Conn.execute("Select UserHead from UserInfo where UserID="&Request.Cookies("User"))(0)&".gif"
	conn.execute("Update UserInfo set UserHead="&FaceName&" where UserID="&Request.Cookies("User"))
	response.write "<body topmargin=0 ><link href=css.css rel=stylesheet><body topmargin=1>"
	response.write "<a target=_blank href=http://"&Request.ServerVariables("server_name")&replace(Request.ServerVariables("path_info"), "upfile.asp", "")&filename&">照片上传成功,请点击查看或按刷新按钮!</a>"
	End Select

	response.end
else
Menu=Trim(Request.QueryString("Menu"))
%>
	<link href=css.css rel=stylesheet>
	<form enctype=multipart/form-data method=post action=upfile.asp?menu=up&M=<%=menu%>>
	<%
	Select Case Menu
	Case "UpFile"
		formPath="images/upfile/"%>
		<body topmargin=0 bgcolor=#BFD3EE>
		<input name="formPath" type="hidden" value=<%=formPath%>>
		<table cellpadding=0 cellspacing=0 width=100% title=上传附件大小限制不能超过100K >
		<tr><td width="28%"><IMG src=images/affix.gif>增加附件</td>
		<td width="72%" ><input type=file style=FONT-SIZE:9pt name=file size="30"> <input style=FONT-SIZE:9pt type="submit" value=" 上 传 " name=Submit></td></tr></table>
	<%Case "UpPhoto"
		formPath="images/upphoto/"%>
		<body topmargin=0>
		<input name="formPath" type="hidden" value=<%=formPath%>>
		<table cellpadding=0 cellspacing=0 width=100% title=上传照片大小限制不能超过30K>
		<tr>
		<td width="100%" ><center><input type=file style=FONT-SIZE:9pt name=file size="24"> <input style=FONT-SIZE:9pt type="submit" value=" 上 传 " name=Submit></center></td></tr></table>
	<%Case "UpFace"
	formPath="images/face/"%>
		<body topmargin=0>
		<input name="formPath" type="hidden" value=<%=formPath%>>
		<table cellpadding=0 cellspacing=0 width=100% title=上传照片大小限制不能超过10K>
		<tr>
		<td width="100%" ><center><input type=file style=FONT-SIZE:9pt name=file size="24"> <input style=FONT-SIZE:9pt type="submit" value=" 上 传 " name=Submit></center></td></tr></table>
	<%
	Case Else
	Error 1,"非法信息传送!\n您的IP已被记录!",""
	End Select
end if%>

⌨️ 快捷键说明

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