最好不用临时文件,数据库字段为image类型的
字段名称为fileBody

解决方案 »

  1.   

    给你个例子
    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
    需要建立一个新的页面,在新的页面里下载
      

  2.   

    Response.ContentType = "Application/octet-stream"
            Response.Clear()
            Response.AddHeader("Content-Disposition", " filename=" + Session("sFileName"))
            Response.BinaryWrite(Session("Buffer"))
            Response.End()