开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜