jixinyu12345

页面调用 

function fnOpen(path) {
window.open("~/FileHelp.ashx? url=");
//window.open(url);
}

 

后台一般处理程序  

var myWebClient = new WebClient();
var url = context.Request["url"];
var cread = new NetworkCredential("账号", "密码", "domain");
myWebClient.Credentials = cread;
var fs = new FileStream(@"", FileMode.Open, FileAccess.Read);

byte[] bytes = new byte[(int)fs.Length];
fs.Read(bytes, 0, bytes.Length);
context.Response.ContentType = "application/octet-stream";
//通知浏览器下载文件而不是打开
context.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode("sf.jpg", System.Text.Encoding.UTF8));
context.Response.BinaryWrite(bytes);
context.Response.Flush();

 

 

  • 首先我们要在服务器本地上访问到 对应的文件夹,否则 你怎么做 都是无效的

 

分类:

技术点:

相关文章:

  • 2022-03-01
  • 2022-12-23
  • 2022-12-23
  • 2022-02-02
  • 2022-12-23
  • 2021-12-09
  • 2021-11-29
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
  • 2021-12-14
  • 2022-03-03
  • 2021-11-30
相关资源
相似解决方案