开发者

How To Raise a "File Download" in ASP and prevent hotlink

开发者 https://www.devze.com 2023-02-10 09:01 出处:网络
I have this code in 开发者_StackOverflowPHP: header(\"Content-Type: application/vnd.ms-excel\"); header(\"Content-Type: application/download\");

I have this code in 开发者_StackOverflowPHP:

header("Content-Type: application/vnd.ms-excel");
header("Content-Type: application/download");
header("Content-Length: ".filesize($path.$filename));
header("Content-disposition: attachment; filename=" . urlencode($filename));
readfile($path.$filename);

In first time, i use this in asp:

<%
    Response.AddHeader "content-disposition","attachment; filename=download.xls"
%>

I prevent "hotlink" too


Set ObjStr = Server.CreateObject("ADODB.Stream")
ObjStr.Type = 1 'AdBinary – Binário
ObjStr.Open

ObjStr.LoadFromFile "D:\Folder\edital.pdf"

varBuffer = ObjStr.Read

Response.buffer = true

Response.AddHeader "content-disposition","attachment;"
Response.ContentType = "application/pdf"
Response.CacheControl = "public"

Response.BinaryWrite varBuffer
0

精彩评论

暂无评论...
验证码 换一张
取 消