?? upme.asp
字號:
<!--#include file="conn.asp"-->
<!--#include file="ConnUser.asp"-->
<!--#include file="config.asp"-->
<!--#include file="Inc/config.asp"-->
<!--#include file="Inc/upload.asp"-->
<!--#include file="ChkUser.asp" -->
<%
dim upload,file,formName,SavePath,SaveSecondPath,filename,fileExt,FileExtPath
dim upNum
dim EnableUpload
dim Forumupload
dim ranNum
dim uploadfiletype
dim msg,founderr
msg=""
founderr=false
EnableUpload=false
SavePath = (FileUploadPath) '存放上傳文件的目錄
if right(SavePath,1)<>"/" then SavePath=SavePath&"/" '在目錄后加(/)
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<%
call upload_0() '使用化境無組件上傳類
%>
</body>
</html>
<%
sub upload_0() '使用化境無組件上傳類
set upload=new upload_file '建立上傳對象
for each formName in upload.file '列出所有上傳了的文件
set file=upload.file(formName) '生成一個文件對象
if file.filesize<100 then
msg="請先選擇你要上傳的文件!"
founderr=true
end if
if file.filesize>(MaxFileSize*1024) then
msg="文件大小超過了限制,最大只能上傳" & CStr(MaxFileSize) & "K的文件!"
founderr=true
end if
fileExt=lcase(file.FileExt)
Forumupload=split(UpFileType,"|")
for i=0 to ubound(Forumupload)
EnableUpload=false
if fileEXT=trim(Forumupload(i)) then
EnableUpload=true
exit for
end if
next
if fileEXT="asp" or fileEXT="asa" or fileEXT="aspx" or fileEXT="cer" or fileEXT="cdx" then
EnableUpload=false
end if
if EnableUpload=false then
msg="這種文件類型不允許上傳!\n\n只允許上傳這幾種文件類型:" & UpFileType
founderr=true
end if
strJS="<SCRIPT language=javascript>" & vbcrlf
if founderr<>true then
SaveSecondPath=year(now)&"-"&month(now)
FileExtPath=LCase(fileExt)
ServePath=server.mappath(SavePath)
Set fso=server.createobject("scripting.filesystemobject")
'response.write ServePath & vbcrlf
if fso.FolderExists(ServePath) then
'檢查Config.asp中設置的上傳目錄,無則自動建立
else
Set f = fso.CreateFolder(ServePath)
set f=nothing
End if
'response.write ServePath &"\"& FileExtPath & vbcrlf
if fso.FolderExists(ServePath &"\"& FileExtPath) then
'檢查上傳目錄有沒有上傳文件類型(擴展名)目錄,無則自動建立
else
Set f = fso.CreateFolder(ServePath &"\"& FileExtPath)
set f=nothing
End if
'response.write ServePath &"\"& FileExtPath &"\"& SaveSecondPath & vbcrlf
if fso.FolderExists(ServePath &"\"& FileExtPath &"\"& SaveSecondPath) then
'檢查上傳目錄有沒有本年月目錄,無則自動建立
else
Set f = fso.CreateFolder(ServePath &"\"& FileExtPath &"\"& SaveSecondPath)
set f=nothing
End if
set fso=nothing
randomize
ranNum=int(900*rnd)+100
SaveFileName=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
filename=SavePath & FileExtPath &"/"& SaveSecondPath &"/"& SaveFileName
fillle="附件"
file.SaveToFile Server.mappath(FileName) '保存文件
filename1= FileExtPath &"/"& SaveSecondPath &"/"& SaveFileName
set rs=server.createobject("adodb.recordset")
sql="select * from "& db_UploadPic_Table
rs.open sql,conn,1,3
rs.addnew
rs("picname")=filename1
username=request.cookies(Forcast_SN)("username")
rs("username")=username
rs.update
rs.close
set rs=nothing
msg="上傳文件成功!"
strJS=strJS & "content=parent.message.document.body.innerHTML;"
FileType=right(fileExt,3)
strJS=strJS & "content=content+'請點擊圖標下載瀏覽:<br><a href="& filename &"><img border=0 src=images/"&FileType&".gif></a><br>"& fillle &"';" & vbcrlf
strJS=strJS & "parent.message.document.body.innerHTML=content;" & vbcrlf
end if
strJS=strJS & "alert('" & msg & "');" & vbcrlf
strJS=strJS & "history.go(-1);" & vbcrlf
strJS=strJS & "</script>"
response.write strJS
set file=nothing
next
set upload=nothing
end sub
%>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -