?? 復(fù)件 add_creatroom.asp
字號:
<!--#include file="upload.inc.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="checkpwd.asp"-->
<%
'===========無組件上傳(upload_0)====================
dim upload,file,formName,formPath,filename,fileExt
dim ranNum
call UpFile()
'===========無組件上傳(upload_0)====================
sub UpFile()
set upload=new UpFile_Class '建立上傳對象
upload.GetData (500*1024) '取得上傳數(shù)據(jù),此處即為500 K
if upload.err > 0 then
select case upload.err
case 1
Response.Write("<script>alert(""請先選擇你要上傳的圖片!"");location.href=history.go(-1);</script>")
'Response.Write "請先選擇你要上傳的文件 [ <a href=# onclick=history.go(-1)>重新上傳</a> ]"
case 2
Response.Write("<script>alert(""圖片大小超過了限制 500 K!"");location.href=history.go(-1);</script>")
'Response.Write "圖片大小超過了限制 500 K [ <a href=# onclick=history.go(-1)>重新上傳</a> ]"
end select
exit sub
else
formPath=upload.form("filepath") '文件保存目錄,此目錄必須為程序可讀寫
if formPath="" then
formPath="../upload"
end if
'在目錄后加(/)
if right(formPath,1)<>"/" then
formPath=formPath&"/"
end if
for each formName in upload.file '列出所有上傳了的文件
set file=upload.file(formName) '生成一個(gè)文件對象
if file.filesize<100 then
Response.Write("<script>alert(""請先選擇你要上傳的圖片!"");location.href=history.go(-1);</script>")
'response.write "請先選擇你要上傳的圖片 [ <a href=# onclick=history.go(-1)>重新上傳</a> ]"
response.end
end if
fileExt=lcase(file.FileExt)
if CheckFileExt(fileEXT)=false then
response.write "文件格式不正確 [ <a href=# onclick=history.go(-1)>重新上傳</a> ]"
response.end
end if
'randomize
ranNum=int(90000*rnd)+10000
filename=formPath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
if file.FileSize>0 then '如果 FileSize > 0 說明有文件數(shù)據(jù)
result=file.SaveToFile(Server.mappath(filename)) '保存文件
if result="ok" then
response.write formName&" upload OK, had saved to "&filename&"<br>"
else
response.write formName&" upload Fail,"&result&"<br>"
end if
end if
set file=nothing
next
set upload=nothing
end if
end sub
'判斷文件類型是否合格
Private Function CheckFileExt (fileEXT)
dim Forumupload
Forumupload="gif,jpg,bmp,jpeg"
Forumupload=split(Forumupload,",")
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
roomnam=request.Form("roomnam")
descrip=request.Form("descrip")
price=request.Form("price")
totnum=request.Form("totnum")
if not filename="" then
sql="insert into [room] (roomnam,descrip,price,pic,lnum,totnum) values('"&roomnam&"','"&descrip&"','"&price&"','"&filename&"','"&totnum&"','"&totnum&"')"
conn.execute(sql)
end if
'===========無組件上傳(upload_0)====================
%>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -