给个例子你
public static void filedown(string fileid)//文件下载
{
HttpResponse clsreponse=System.Web.HttpContext.Current.Response;
SqlDataReader qq;
qq=Sqlop.ExecuteReader("SELECT fileName, fileContext FROM CRDFILE WHERE fileid='" +fileid+"'");
if (qq.Read())
{
clsreponse.ClearHeaders();
clsreponse.ClearContent();
clsreponse.AddHeader("Content-Disposition", "attachment; filename=" + qq["fileName"].ToString().Trim());
Byte[] context =(Byte[])qq["fileContext"];
clsreponse.OutputStream.Write(context, 0, context.Length);
clsreponse.End();
}
else
{
basefun.alt_sun("No file found!");
}
qq.Close();
}
public static void filedown(string fileid)//文件下载
{
HttpResponse clsreponse=System.Web.HttpContext.Current.Response;
SqlDataReader qq;
qq=Sqlop.ExecuteReader("SELECT fileName, fileContext FROM CRDFILE WHERE fileid='" +fileid+"'");
if (qq.Read())
{
clsreponse.ClearHeaders();
clsreponse.ClearContent();
clsreponse.AddHeader("Content-Disposition", "attachment; filename=" + qq["fileName"].ToString().Trim());
Byte[] context =(Byte[])qq["fileContext"];
clsreponse.OutputStream.Write(context, 0, context.Length);
clsreponse.End();
}
else
{
basefun.alt_sun("No file found!");
}
qq.Close();
}
解决方案 »
- ASP.NET 上插入视频
- 【郁闷死了】过程或函数 'CheckUser' 需要参数 '@userName',但未提供该参数。
- c# .net 登录远程服务器问题
- 【求助】ASP.NET中的两个小问题
- 有个问题大家可能不太重视 关于!DOCTYPE 请专业人士解惑。
- datagrid控件模板列中的按钮的触发事件怎么写?
- .net开发的OA,在装有上网助手的机器上不能运行?
- webbrowser 打开网页中链接
- 在asp.net中要同时使用两种脚本怎么办?
- .net的上传问题:高手门,在.net里上传文件有大小的限制吗?
- 如何得到dataGrid控件处理事件的过程?
- 如何知道某条记录在数据集中的位置
Response.AddHeader("Content-Disposition", "attachment; filename=" + m_Dtl.Rows[0]["AttachmentSourceName"].ToString());
Response.Charset = "UTF-8";
Response.ContentType=m_Dtl.Rows[0]["AttachmentContentType"].ToString();
Response.BinaryWrite((byte[])m_Dtl.Rows[0]["AttachmentContent"]);其中
ContentType = FileNew.PostedFile.ContentType;
表示附件的MIME类型
不行呀,还是有提示保存的对话框呀
因为下载到客户端好办。上载有一定难度
Response.ContentType