<%
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
%>
