如果解决在读取sql server数据库中二进制流字段后,下载时给予文件名?

我是使用lyfupload 1.2 的 ASP 的 上传组件

将DOC文档上传到 SQL SERVER 的 表中 image类型的字段 中

当 用户 点击 相关链接的时候 asp 在通过这个组件 从 数据库表中的相应记录中 调出这个 二进制流 并赋予DOC类型

问题就是 当跳出下载框的 时候的 默认文件名均为 pictest.doc (文件主名就是我的ASP文件的名字) 现在我想把默认的文件名设置成与它对应的文件名(每一个都肯定不同的),

我现在把PICTEST.asp(就是那个用户点击链接后,对应处理的asp 文档) 代码贴出来

 1   
 2Function SetForDisplay(field, contentType)   
 3  
 4contentType = contentType   
 5nFieldSize = field.ActualSize   
 6bytes = field.GetChunk(nFieldSize)   
 7  
 8Session("Bytes") = bytes   
 9Session("Type") = contentType   
10End Function   
11  
12Dim Recordset1__MMColParam   
13Recordset1__MMColParam = "9999"   
14If (Request.QueryString("id") <> "") Then   
15Recordset1__MMColParam = Request.QueryString("id")   
16End If   
17  
18  
19Set oRS = Server.CreateObject("ADODB.Recordset")   
20oRS.ActiveConnection = dsnname   
21oRS.Source = "SELECT * FROM item where id="+Recordset1__MMColParam   
22oRS.CursorLocation = 3   
23oRS.Open()   
24  
25SetForDisplay oRS("fjian"), "application/msword" '"image/gif" 为MIME类型   
26  
27  
28Set oRS.ActiveConnection = Nothing   
29  
30  
31response.Expires = 0   
32  
33response.Buffer = True   
34  
35response.Clear   
36  
37response.contentType = Session("Type")   
38  
39response.BinaryWrite Session("Bytes")   
40  
41Session("Type") = ""   
42  
43Session("Bytes") = ""   
44  
45response.End   
46  

---------------------------------------------------------------
Response.buffer = TRUE
Response.ContentType = "APPLICATION/OCTET-STREAM"
response.AddHeader "Content-Disposition","attachment;filename=" &clng(request("DateCount"))&".arz"
Response.BinaryWrite rs("U_tbl_file_sw")

Published At
Categories with Web编程
comments powered by Disqus