ASP reads binary file data code from the database

xiaoxiao2021-03-06  56

<% driver_name1 = "driver = {Microsoft Access Driver (* .mdb)}; dbq = d: / database /tree.mdb" The database opens the statement in the root directory

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 thrrs, "error: can't find this file" Response.end endiff

'Set the file size and MIME type Function SetForDisplay (field, contentType) contentType = LCase (trim (contentType)) nFieldSize = field.ActualSizebytes = field.GetChunk (nFieldSize) Session ( "Bytes") = bytesSession ( "Type") = contentTypeEnd Function SetForDisplay RS ( "File"), rs ( "FileType") 'Response.AddHeader "Content-Disposition", "attachment; filename =" & rs ( "fileName") response.contentType = Session ( "Type") response .Binarywrite session ("bytes") session ("type") = "" "" ") =" "

SET RS = Nothing my_conn.close set my_conn = Nothing%>

转载请注明原文地址:https://www.9cbs.com/read-111769.html

New Post(0)