?? editsave.asp
字號:
<%
ID=session("edit_id")
session("edit_id")=""
if id="" then
response.Write "<script langurage=javascript> alert('對不起, 您沒有訪問權(quán)限!')</script>"
response.End
end if
%>
<!--#include FILE="clsUp.asp"-->
<!--#include file="conn.asp"-->
<%
Server.ScriptTimeout=600
dim upfile,formPath,ServerPath,FSPath,FileName,newFilename,path,objfso,sql,rs,conn
set upfile=new clsUp ''建立上傳對象
upfile.NoAllowExt="asp;exe;htm;html;aspx;cs;vb;js;" '設(shè)置上傳類型的黑名單
upfile.GetData (102400000) '取得上傳數(shù)據(jù),限制最大上傳10M
%>
<html>
<head>
<title>文件上傳</title>
<style type="text/css">
<!--
.p9{ font-size: 9pt; font-family: 宋體 }
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body leftmargin="20" topmargin="20" class="p9">
<%
if upfile.isErr then '如果出錯
select case upfile.isErr
case 1
Response.Write "請上傳修改后稿件"
case 2
Response.Write "你上傳的文件超出我們的限制,最大10M"
end select
else
%>
<%
FSPath=GetFilePath(Server.mappath("upfile.asp"),"\")'取得當(dāng)前文件在服務(wù)器路徑
ServerPath=GetFilePath(Request.ServerVariables("HTTP_REFERER"),"/")'取得在網(wǎng)站上的位置
FileName=upfile.file("file").filename'原來的文件名
newfilename=upfile.AutoSave("file",FSPath&"upload\"&FileName) ''保存文件 也可以使用SaveToFile來保存,參數(shù)一樣,但是不會自動建立新的文件名
%>
<%
if upfile.iserr then
Response.Write upfile.errmessage
else
sql="select * from file where id="&id
rs.open sql,conn,1,3
rs("oldfilename")=rs("filename")
rs("filename")=newfilename
rs("zt")=7
rs("olddate")=rs("date")
rs("date")=date()'=在數(shù)據(jù)庫里插入當(dāng)前的時間,格式為年,月,日
rs.update
set upfile=nothing '刪除此對象
response.Redirect("login_ok.asp")
end if
end if
%>
</body>
</html>
<%
function GetFilePath(FullPath,str)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, str))
Else
GetFilePath = ""
End If
End function
%>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -