如何下载已经存储在数据库中的文件?
我手中有一个小的系统,在这个系统中,象什么DOC,RAR,TXT之类的文件都存储在一个数据表中,现在要为它们提供一个下载,应该怎么写原码?
象这样行吗?
set Rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = 3
set doc=Server.CreateObject("Doc.Download")
strsql = "select a.doc_name,a.doc_content,b.doc_type_Suffix from tb_doc a,tb_doc_type b " & _
"where a.doc_type_code=b.doc_type_code and a.doc_code=" & request("doc_code")
Set rs= conn.Execute(strsql)
If Not rs.EOF Then
strFileName= server.MapPath("./") & "\download\" & rs.Fields("doc_name") & rs.Fields("doc_type_Suffix")
strDown="<a href='download/" & rs.Fields("doc_name") & rs.Fields("doc_type_Suffix") & "'>点击下载</a>"
doc.FileName=strFileName
doc.BlobColumn=rs.Fields("doc_content")
doc.ReadbolbToFile
End If