?? upfile1.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 + -