页面的下载应用

<a href="HandlerDownLoad.ashx?file=07.jpg">下载</a>

 

HandlerDownLoad.ashx代码

public class HandlerDownLoad : IHttpHandler { public void ProcessRequest (HttpContext context) { string fileName = context.Request.QueryString["file"]; context.Response.AddHeader("Content-Disposition","attachment;filename=" + context.Server.UrlEncode( fileName)); string path = context.Request.MapPath("images/upload/" + fileName);//找到路径 context.Response.WriteFile(path); } public bool IsReusable { get { return false; } } }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2021-07-12
  • 2021-07-16
  • 2021-05-26
  • 2021-10-04
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-06
  • 2022-02-16
  • 2021-08-22
  • 2022-12-23
相关资源
相似解决方案