readdoc.asp

来自「本示例综合展示了NTKO OFFICE文档控件所具有的发布为HTML」· ASP 代码 · 共 44 行

ASP
44
字号
<%@ Language=VBScript %>
<!--#include file="conn.asp"-->
<%
	'从数据库中读取在线编辑的文件数据
	docid	= Request.querystring("docid")
	Dim	RS
	Set	RS = Server.CreateObject("ADODB.Recordset")

	if docid <> "" then
			RS.Open	"files", conn, adOpenStatic, adLockReadOnly	'open static for search,read only
			RS.Find	"fid=" &	docid
			If Not RS.EOF THEN
				FileSize = RS("fcontent").ActualSize	
				Response.AddHeader "Content-Disposition","attachment; filename=" & RS("fname")
				Response.AddHeader "Content-Length",""  & FileSize
				readBytes = 0
				ReadSize = 10240				
			    Do While readBytes < FileSize
			        Response.BinaryWrite(RS("fcontent").GetChunk(ReadSize))			        
			        Response.Flush()
			        readBytes = readBytes + ReadSize
			    Loop				
			end if
	ELSE
			docid = Request.querystring("tid")
			RS.Open	"templates", conn, adOpenStatic, adLockReadOnly	'open static for search,read only
			RS.Find	"tid=" &	docid
			If Not RS.EOF THEN
				FileSize = RS("tcontent").ActualSize	
				Response.AddHeader "Content-Disposition","attachment; filename=" & RS("tname")
				Response.AddHeader "Content-Length",""  & FileSize
				readBytes = 0
				ReadSize = 10240				
			    Do While readBytes < FileSize
			        Response.BinaryWrite(RS("tcontent").GetChunk(ReadSize))			        
			        Response.Flush()
			        readBytes = readBytes + ReadSize
			    Loop
			END IF
	end if
	RS.Close
	Set	Rs=	Nothing
	Closeconn()
%>

⌨️ 快捷键说明

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