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

📄 upfile1.asp

📁 Flash动画园
💻 ASP
字号:
<!--#include file="check.asp"-->
<!--#include file="upload1.inc"-->
<html>
<head>
<STYLE>TD {
	FONT-SIZE: 9pt; LINE-HEIGHT: 140%
}
BODY {
	FONT-SIZE: 9pt; LINE-HEIGHT: 140%
}
A:link {
	COLOR: #0033cc; TEXT-DECORATION: none
}
A:visited {
	COLOR: #0033cc; TEXT-DECORATION: none
}
A:active {
	COLOR: #4D9CC8; TEXT-DECORATION: none
}
A:hover {
	COLOR: #4D9CC8; TEXT-DECORATION: underline
}
</STYLE>
<title>文件上传</title>
</head>
<body text=#4D9CC8 bgColor=#ffffff  leftMargin=0 topMargin=0>
<table width=100% border=0  cellspacing="0" cellpadding="0"><tr><td>
<script>
parent.document.forms[0].change.disabled=false;
</script>
<%
Server.ScriptTimeOut=999999
dim upload_type
dim upload,file,formName,filename,fileExt
dim ranNum
upload_type=0	'上传方法,0=无组件,1=Lyfupload,2=Aspupload3.0,3=关闭上传功能

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

'判断文件类型是否符合要求
Private Function CheckFileExt (fileEXT)
dim filetype
filetype="asp,asa,aspx"
filetype=split(filetype,",")
	for i=0 to ubound(filetype)
		if lcase(fileEXT)=lcase(trim(filetype(i))) then
			CheckFileExt=false
			exit Function
		else
			CheckFileExt=true
		end if
	next
End Function

'===========无组件上传(upload_0)====================
sub upload_0()
set upload=new UpFile_Class ''建立上传对象
upload.GetDate (10485760)   '取得上传数据,括号内为文件大小限制
 
if upload.err > 0 then
    select case upload.err
	case 1
	Response.Write "请首先选择您要上传的文件 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
	case 2
	Response.Write "文件太大,请压缩后再上传(文件大小不得超过10M) [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
	end select
	set upload=nothing
	exit sub
else

for each formName in upload.file ''列出所有上传了的文件
 set file=upload.file(formName)  ''生成一个文件对象
 fileExt=lcase(file.FileExt)
'判断文件类型
 if CheckFileExt(fileEXT)=false then
	set upload = nothing
	set file = nothing
 	response.write "禁止上传asp和asa文件 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
	exit sub
 end if

randomize
ranNum=int(90000*rnd)+10000
 filename="../Flash_swf/"&session("teacherid")&"at"&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
 downname="Flash_swf/"&session("teacherid")&"at"&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
 if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据
  file.SaveToFile Server.mappath(filename)   ''保存文件
  response.write "请复制作 品地址到连接地址处:"
  response.write "<input type=text name=T1 size=50 value="&downname&">"
 else
  Response.Write "不得上传大小为0的文件 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
 end if
 set file=nothing
next
set upload=nothing
end if
end sub

'===========Lyfupload组件上传(upload_1)=========================
sub upload_1()
	dim obj,filename,fileExt_a
	dim ss
	Set obj = Server.CreateObject("LyfUpload.UploadFile")
	'文件大小限制
    	obj.maxsize=10485760
	
	if obj.request("fname")="" or isnull(obj.request("fname")) then
	Response.Write "请首先选择您要上传的文件 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
	exit sub
	end if
	randomize
	ranNum=int(90000*rnd)+10000
	fileExt_a=split(obj.request("fname"),".")
	fileExt=lcase(fileExt_a(ubound(fileExt_a)))

	if CheckFileExt(fileEXT)=false then
		set obj = nothing
 		response.write "禁止上传asp和asa文件 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
		exit sub
	end if

	filename=session("teacherid")&"at"&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum
	filename=filename&"."&fileExt

	ss=obj.SaveFile("file1",Server.MapPath("../Flash_swf/"), true,filename)

	if ss= "3" then
   		Response.Write ("文件名重复! [ <a href=# onclick=history.go(-1)>重新上传</a> ]")
		set obj=nothing
		exit sub
	elseif ss= "0" then
   		Response.Write ("文件太大,请压缩后再上传(文件大小不得超过10M) [ <a href=# onclick=history.go(-1)>重新上传</a> ]")
		set obj=nothing
		exit sub
	elseif ss = "" then
 		Response.Write ("上传失败! [ <a href=# onclick=history.go(-1)>重新上传</a> ]")
		exit sub
	else
		response.write "请复制作 品地址到连接地址处:"
                response.write "<input type=text name=T1 size=50 value='Flash_swf/"&filename&"'>"
		set obj=nothing
		exit sub
	end if
end sub



''===========================Aspupload3.0组件上传============================
sub upload_2()
dim Count
on error resume next
Set Upload = Server.CreateObject("Persits.Upload") 
Upload.OverwriteFiles = false   '不允许覆盖重名文件
Upload.IgnoreNoPost = True
Upload.SetMaxSize 10485760, True	 '文件大小限制

Count = Upload.Save
If Err.Number = 8 Then 
   Response.Write "文件太大,请压缩后再上传(文件大小不得超过10M) [ <a href=# onclick=history.go(-1)>重新上传</a> ]" 
Else 
   If Err <> 0 Then 
      Response.Write "错误信息: " & Err.Description 
   Else
		If Count < 1 Then 
		Response.Write "请首先选择你要上传的文件 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
		set Upload =nothing
		exit sub
		End If
	For Each file in Upload.Files	'列出所有上传文件
	fileExt=lcase(replace(File.ext,".",""))
	'判断文件类型
	if CheckFileExt(fileEXT)=false then
	set upload = nothing
 	response.write "禁止上传asp和asa文件 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
	exit sub
	end if
	'文件变量付值
	randomize
	ranNum=int(90000*rnd)+10000
	filename=session("teacherid")&"at"&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&File.ext
        downname="Flash_swf/"&filename
	filename="../Flash_swf/"&filename
	file.saveas Server.MapPath(filename)	'上传保存文件
	response.write "请复制作 品地址到连接地址处:"
        response.write "<input type=text name=T1 size=50 value="&downname&">"
	Next
   End If 
End If
set Upload = nothing
end sub
%>
</td></tr></table>
</body>
</html>

⌨️ 快捷键说明

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