downfile.asp
来自「绿叶oa系统办公自动化 2008.工作日志管理,文件管理」· ASP 代码 · 共 175 行
ASP
175 行
<%
Response.ExpiresAbsolute=now()-1
Response.CacheControl="no-cache"
%>
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers=""
MM_authFailedURL="../../index.asp"
MM_grantAccess=false
If Session("userssdfgfhtrh") <> "" Then
If (true Or CStr(Session("MM_UserAuthorization"))="") Or _
(InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
MM_grantAccess = true
End If
End If
If Not MM_grantAccess Then
MM_qsChar = "?"
If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
MM_referrer = Request.ServerVariables("URL")
if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
Response.Redirect(MM_authFailedURL)
End If
%>
<%
if(request("id") <> "") then Command1__varid = request("id")
%>
<%
if(request("id") <> "") then Command11__varff = request("id")
%>
<% dim u,names,b,id
u=Session("userssdfgfhtrh")
names=Session("names")
b=Session("bumen")
id=request("id")
gwid=request("gwid")
%>
<!--#include file="../../Connections/oavbsconn.asp" -->
<%
Dim geturl__MMColParam
geturl__MMColParam = "1"
If (Request("id") <> "") Then
geturl__MMColParam = Request("id")
End If
%>
<%
Dim geturl
Dim geturl_numRows
Set geturl = Server.CreateObject("ADODB.Recordset")
geturl.ActiveConnection = MM_oavbsconn_STRING
geturl.Source = "SELECT 文件路径 FROM fawenfiles WHERE id = " + Replace(geturl__MMColParam, "'", "''") + ""
geturl.CursorType = 0
geturl.CursorLocation = 2
geturl.LockType = 1
geturl.Open()
geturl_numRows = 0
%>
<%if not geturl.eof or not geturl.bof then
dim url
url=geturl("文件路径")
end if
%>
<%
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If not objFSO.FileExists(Server.MapPath(url)) Then%>
<script language='Javascript'>
{
alert('抱歉,您要的文件在服务器上未找到!');history.go(-1)
}
</script>
<%
response.end()
End If%>
<%
geturl.Close()
Set geturl = Nothing
%>
<%dim p,fn%>
<%p=url
fn=mid(url,48)%>
<%
if(request("id") <> "") then Command1__varid = request("id")
%>
<%
set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = MM_oavbsconn_STRING
Command1.CommandText = "UPDATE 文件信息info SET 下载人数=下载人数+1,下载次数=下载次数+1 WHERE id=" + Replace(Command1__varid, "'", "''") + " "
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()
%>
<%
if(request("id") <> "") then Command11a__varff = request("id")
%>
<%
set Command11a = Server.CreateObject("ADODB.Command")
Command11a.ActiveConnection = MM_oavbsconn_STRING
Command11a.CommandText = "UPDATE fawenfiles SET 下载次数=下载次数+1 ,下载人数=下载人数+1 WHERE id=" + Replace(Command11a__varff, "'", "''") + ""
Command11a.CommandType = 1
Command11a.CommandTimeout = 0
Command11a.Prepared = true
Command11a.Execute()
%>
<%
session("regdown")=1
if session("regdown")=1 then
session("regeddown")=session("regeddown")+1
end if
%>
<%
set Command11 = Server.CreateObject("ADODB.Command")
Command11.ActiveConnection = MM_oavbsconn_STRING
Command11.CommandText = "UPDATE fawenfiles SET 下载次数=下载次数+1 WHERE id=" + Replace(Command11__varff, "'", "''") + " "
Command11.CommandType = 1
Command11.CommandTimeout = 0
Command11.Prepared = true
Command11.Execute()
%>
<%
Dim sum__MMColParam
sum__MMColParam = "1"
If (Request("gwid") <> "") Then
sum__MMColParam = Request("gwid")
End If
%>
<%
Dim sum
Dim sum_numRows
Set sum = Server.CreateObject("ADODB.Recordset")
sum.ActiveConnection = MM_oavbsconn_STRING
sum.Source = "SELECT sum(下载人数) as allren,sum(下载次数) as allrenci FROM 文件信息info WHERE 邮件编号 = " + Replace(sum__MMColParam, "'", "''") + ""
sum.CursorType = 0
sum.CursorLocation = 2
sum.LockType = 1
sum.Open()
sum_numRows = 0
%>
<%dim juti
juti="下载"%>
<%
call downloadFile(url)
'call downloadFile(Request("文件路径"))
function downloadFile(strFile)
strFilename = server.MapPath(strFile)
Response.Buffer = True
Response.Clear
Set s = Server.CreateObject("ADODB.Stream")
s.Open
s.Type = 1
on error resume next
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if not fso.FileExists(strFilename) then
Response.Write("<h1>Error:</h1>" & strFilename1 & "文件不存在<p>")
Response.End
end if
Set f = fso.GetFile(strFilename)
intFilelength = f.size
s.LoadFromFile(strFilename)
if err then
Response.Write("<h1>Error: </h1>" & err.Description & "<p>")
Response.End
end if
Response.AddHeader "Content-Disposition", "attachment; filename=" & f.name
Response.AddHeader "Content-Length", intFilelength
Response.CharSet = "UTF-8"
Response.ContentType = "application/octet-stream"
Response.BinaryWrite s.Read
Response.Flush
s.Close
Set s = Nothing
End Function
%>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?