文件上传到数据库中,如何下载呢?? 最好不用临时文件,数据库字段为image类型的字段名称为fileBody 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给你个例子if(Request.QueryString["AttachmentID"] != null){ SqlCommand command = new SqlCommand("SELECT * from Flow_Attachments where Flow_AttachmentsID=" + Request.QueryString["AttachmentID"],myConnection); myConnection.Open(); SqlDataReader dr = command.ExecuteReader(); if(dr.Read()) { Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(dr[1].ToString())); Response.BinaryWrite((byte[])dr[4]); } dr.Close(); myConnection.Close();}//数据库CREATE TABLE [dbo].[Flow_Attachments] ( [Flow_AttachmentsID] [int] IDENTITY (1, 1) NOT NULL , [Flow_AttachmentsName] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL , [Flow_AttachmentsType] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL , [Flow_Description] [varchar] (200) COLLATE Chinese_PRC_CI_AS NULL , [Flow_AttachmentsImage] [image] NULL , [Flow_AttachmentsCourseID] [int] NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]GO需要建立一个新的页面,在新的页面里下载 Response.ContentType = "Application/octet-stream" Response.Clear() Response.AddHeader("Content-Disposition", " filename=" + Session("sFileName")) Response.BinaryWrite(Session("Buffer")) Response.End() url正则表达式判断问题 写入数据库问题,求救高手,急! 郁闷,asp.net2.0 中水晶报表没有工具栏? DataGrid可以实现横排数据吗? 我在IIS里建了个站点的虚拟目录,为什么访问的时候提示错误说"访问 IIS 元数据库失败"? 突然之间,web应用不能调试了 我的IIS为什么不能连接SQl啊? 请问购物订单表如何设计 怎样返回表中某列某行的值? (火急~~)谁有汉字转拼音的对应数据库的。详情请进 遇到一个HyperLink按钮的问题 地址栏的回车事件怎么写呀
if(Request.QueryString["AttachmentID"] != null)
{
SqlCommand command = new SqlCommand("SELECT * from Flow_Attachments where Flow_AttachmentsID=" + Request.QueryString["AttachmentID"],myConnection);
myConnection.Open();
SqlDataReader dr = command.ExecuteReader();
if(dr.Read())
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(dr[1].ToString()));
Response.BinaryWrite((byte[])dr[4]);
}
dr.Close();
myConnection.Close();
}//数据库
CREATE TABLE [dbo].[Flow_Attachments] (
[Flow_AttachmentsID] [int] IDENTITY (1, 1) NOT NULL ,
[Flow_AttachmentsName] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
[Flow_AttachmentsType] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[Flow_Description] [varchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
[Flow_AttachmentsImage] [image] NULL ,
[Flow_AttachmentsCourseID] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
需要建立一个新的页面,在新的页面里下载
Response.Clear()
Response.AddHeader("Content-Disposition", " filename=" + Session("sFileName"))
Response.BinaryWrite(Session("Buffer"))
Response.End()