最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
ASP中从数据库读取二进制文件数据代码
时间:2022-06-30 10:28:27 编辑:袖梨 来源:一聚教程网
<%
driver_name1="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=D:数据库TREE.MDB" '根目录下数据库打开语句
dim search,rs,j
search="select * from Files where ID=" & request.querystring("ID")
set my_conn=server.CreateObject ("adodb.connection")
my_conn.open driver_name1
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open search,my_conn,1,3
if rs.bof or rs.eof then
response.write "错误:找不到该文件"
response.end
end if
'设置文件的大小及MIME类型
Function SetForDisplay(field, contentType)
contentType = LCase(trim(contentType))
nFieldSize = field.ActualSize
bytes = field.GetChunk(nFieldSize)
Session("Bytes") = bytes
Session("Type") = contentType
End Function
SetForDisplay RS("File"),rs("FileType")
'Response.AddHeader "Content-Disposition", "attachment; filename=" & rs("FileName")
response.contentType = Session("Type")
response.BinaryWrite Session("Bytes")
Session("Type") = ""
Session("Bytes") = ""
set rs=nothing
my_conn.close
set my_conn=nothing
%>
driver_name1="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=D:数据库TREE.MDB" '根目录下数据库打开语句
dim search,rs,j
search="select * from Files where ID=" & request.querystring("ID")
set my_conn=server.CreateObject ("adodb.connection")
my_conn.open driver_name1
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open search,my_conn,1,3
if rs.bof or rs.eof then
response.write "错误:找不到该文件"
response.end
end if
'设置文件的大小及MIME类型
Function SetForDisplay(field, contentType)
contentType = LCase(trim(contentType))
nFieldSize = field.ActualSize
bytes = field.GetChunk(nFieldSize)
Session("Bytes") = bytes
Session("Type") = contentType
End Function
SetForDisplay RS("File"),rs("FileType")
'Response.AddHeader "Content-Disposition", "attachment; filename=" & rs("FileName")
response.contentType = Session("Type")
response.BinaryWrite Session("Bytes")
Session("Type") = ""
Session("Bytes") = ""
set rs=nothing
my_conn.close
set my_conn=nothing
%>
相关文章
- 王者荣耀侦探能力大测试攻略 王者荣耀侦探能力大测试怎么过 11-22
- 无期迷途主线前瞻兑换码是什么 11-22
- 原神欧洛伦怎么培养 11-22
- 炉石传说网易云音乐联动怎么玩 11-22
- 永劫无间手游确幸转盘怎么样 11-22
- 无期迷途主线前瞻兑换码是什么 无期迷途主线前瞻直播兑换码介绍 11-22