⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 downfile.asp

📁 物业管理和办公自动化系统
💻 ASP
字号:
<%
'************************************************************************************************
' 文件名: downfile.asp
' Copyright(c) 2001-2002 上海阿尔卡特网络支援系统有限公司

'  创建人 : 周秋舫
'  日 期 : 2002-08-16
' 修改历史 :
'   ****年**月**日 ****** 修改内容:**************************************************
' 功能描述 : 下载文件内容,文件内容信息是从数据库获取的
'  版 本 :
'************************************************************************************************
option explicit
'Response.CacheControl = "no-cache"
'Response.AddHeader "Pragma", "no-cache"
'Response.Expires = -1
%>

<!-- #include file="../include/common.inc" -->
<!-- #include file="../include/db.inc" -->
<!-- #include file="../include/datahandle.inc" -->

<%
'' 是否已经登录,登录了才有EmpSerial
dim	iEmpSerial	 :	iEmpSerial	 = GetEmpSerial()
if CStr(iEmpSerial) = "" then
	response.clear()
	response.Redirect("../common/error.asp?error=对不起,您没有登录系统!<br><br>可能原因是登录信息已过期,您必须重新登录!")
	response.end
end if

dim	pFileSerial	: pFileSerial = GetParam("serial")
if IsEmpty(pFileSerial) then pFileSerial = 1

'' 这里对文件查看权限作了限制,只有文件的所有者或共享者才能打开该文件
dim sSQL, crs, rs
sSQL = "select filename, contenttype, content from t_files" & _
	" where serial=" & pFileSerial & _
	" and ( emp_serial = " & iEmpSerial & " or PATINDEX('%," & iEmpSerial & ",%', ',' + replace(opento,' ','') + ',') > 0)"

set crs = New CRecordset
set rs = crs.Open(dbLocal, sSQL)

'' 如果找不到查询符合条件的文件,则跳转到出错页面
if rs.eof then
	Response.Clear()
	Server.Transfer("../common/error.asp")
	Response.end
end if
%>

<%

' 设置响应头和下载保存的文件名 
dim filename	: filename = crs.GetValue("filename")
Response.AddHeader "Content-Disposition","attachment;filename=" & filename 
Response.ContentType = "APPLICATION/OCTET-STREAM"
Response.BinaryWrite crs.GetValue("content")
crs.Close()
%> 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -