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

📄 pro_upfile.asp

📁 一个漂亮的网络工作室源码 后台地址:/admin 用户名:admin 密码:admin888
💻 ASP
字号:
<!--#include file="upload.inc"-->
<style type="text/css">
body{
	font-size:12px;
	margin-left: 0px;
	margin-top: 0px;
}
td{
font-size:12px;
}
a:link {  
	color: #000000; 
	text-decoration: none;
}

a:hover {  
	color: #000000; 
	text-decoration: none;
}

a:active { 
	color: #000000; 
	text-decoration: none;
}

a:visited {  
	color: #000000; 
	text-decoration: none;
}
</style>
<script>
parent.document.forms[0].Submit.disabled=false;
parent.document.forms[0].Submit2.disabled=false;
</script>
<%
'===========================无组件上传============================
Server.ScriptTimeOut=999999
Dim upload,File
Dim FormName,FormPath,Filename,File_name,FileExt,Filesize,F_Type,rename,imgpath
Set upload=new UpFile_Class						''建立上传对象

upload.GetDate (3000*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 "文件大小超过了限制 3M [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
	End Select
	response.End()
Else
action=upload.form("action")
FormPath=upload.form("FilePath")'在目录后加(/)
If right(FormPath,1)<>"/" then FormPath=FormPath&"/"


	For Each FormName In upload.File		''列出所有上传了的文件
		Set File=upload.File(FormName)		''生成一个文件对象

		FileExt=Lcase(File.FileExt)
		'判断文件类型
		If CheckFileExt(FileExt)=false then
 			Response.write "文件格式不正确,或不能为空 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
			response.End()
		End If
		'付值变量
		'F_Type		=	CheckFiletype(FileExt)
		File_name	=	CreateName()
		Filename	=	File_name&"."&FileExt
		'rename		=	CreatePath()&Filename&"|"
		Filename	=	FormPath&CreatePath()&Filename
		Filesize	=	File.FileSize
		'记录文件
		If Filesize>0 then								'如果 FileSize > 0 说明有文件

		File.SaveToFile Server.mappath("../"&FileName)		''执行上传文件
		'记录文件
		response.write("文件上传成功&nbsp;&nbsp;[<a href='pro_upload.asp?action="&action&"'>返回</a>]")
        '记录上传个数,文件名写入表单
         call checksave()
		End If
		Set File=Nothing
	Next
End If
Set upload=Nothing

Private sub checksave()
if action="spic" then
 	response.write("<script>parent.frmAnnounce.spic.value='"&filename&"'</script>")
	else
	response.write("<script>parent.frmAnnounce.bpic.value='"&filename&"'</script>")
	end if
end sub

'创建文件名
Private Function CreateName()
Dim ranNum
	randomize
	ranNum=int(999*rnd)
	CreateName=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum
End Function

'按月份自动明名上传文件夹,需要FSO组件支持。
Private Function CreatePath()
Dim objFSO,Fsofolder,uploadpath
uploadpath=year(now)&"-"&month(now)	'以年月创建上传文件夹,格式:2003-8
On Error Resume Next
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
	If objFSO.FolderExists(Server.MapPath("../"&FormPath&uploadpath))=False Then
	objFSO.CreateFolder Server.MapPath("../"&FormPath&uploadpath)
	End If
	If Err.Number = 0 Then
	CreatePath=uploadpath&"/"
	Else
	CreatePath=""
	End If
set objFSO = nothing
End Function


'判断文件类型是否合格
Private Function CheckFileExt (fileEXT)
dim Forumupload,i
Forumupload=split("jpg|gif|bmp","|")
	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

'判断文件类型:0=其它,1=图片,2=FLASH,3=音乐,4=电影
Private Function CheckFiletype(fileEXT)
dim upFiletype
dim FilePic,FileVedio,FileSoft,FileFlash,FileMusic,i
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
%>

⌨️ 快捷键说明

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