原创

H5-实现HTML中下载文件,而不是直接在浏览器中打开-Content-Disposition-download.js

1、
<a href="地址" download="名称"></a>

2、“download.js”
download("url","name","mine") 函数
<div   onclick="download("视频地址","想要起的名称.mp4","video/mp4")"  >下载</div>
附件下载:download.js

3、AddHeader
Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName); //核心
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
Response.AddHeader("Content-Transfer-Encoding", "binary");
Response.ContentType = "application/octet-stream";
正文到此结束
本文目录