欢迎光临
我们一直在努力

ASP中从数据库读取二进制文件数据代码-ASP教程,数据库相关

建站超值云服务器,限时71元/月

<%

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

%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » ASP中从数据库读取二进制文件数据代码-ASP教程,数据库相关
分享到: 更多 (0)

相关推荐

  • 暂无文章