Download files stored in the image field of SQL7 to the client's ASP source code
File Name: Download.asp Usage: Download.asp? FID = XXX Description: Download files stored in SQL7 to the client database structure: [Name] TabiMage {FID NOT NULL; FileName Varchar (100) Notn Null; filecontent image not null} FID: File ID [PK]; filename: file name; filecontent: file binary content
<% Response.buffer = truevarfileid = Request ("FID") if varfileid = "" "" "" response.endendiff) without specifying the download file ID.
OpenDB connSQL = "SELECT filename, filecontent FROM tabimage WHERE fid =" & varfileidSet rs = conn.Execute (SQL) If Not rs.Eof Then varfilename = rs ( "filename") varfilesize = rs ( "filecontent"). ActualSize varcontent = rs ( "filecontent") GetChunk (varfilesize) Response.ContentType = "* / *" Response.AddHeader "Content-Length", varfilesize Response.AddHeader "Content-Disposition",. "attachment; filename =" "" & varfilename & "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
'Connecting the Database General Procedure SUB OPENDB (Byref Conn) Set Conn = Server.createObject ("AdoDb.Connection") Conn.Provider = "SQLOLEDB" Conn.connectionstring = "Driver = {SQL Server}; server = xxx.xxx.xxx .xxx; uid = myusername; pwd = mypassword; database = myDatabase "conn.openend sub%>