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
精彩评论