62,073
社区成员
发帖
与我相关
我的任务
分享
if (context.Request.QueryString["FileID"] != null && context.Request.QueryString["FileID"] != "")
{
int id = Convert.ToInt32(context.Request.QueryString["FileID"]);
AttachFile file = BOProxyFactory.CreateBoProxy<AttachBO>().Get(id);
if (file != null && file.AttachContent != null)
{
context.Response.Clear();
context.Response.AppendHeader("Content-Type", "application/octet-stream"); context.Response.Charset = "utf-8";
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
context.Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(file.AttachName, System.Text.Encoding.UTF8));
context.Response.BinaryWrite(file.AttachContent);
context.Response.End();
}
else
{
context.Response.ContentType = "text/plain";
context.Response.Write("文件不存在");
context.Response.End();
}
}