celsowm
celsowm

Reputation: 404

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

I have this code in PHP:

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

Upvotes: 2

Views: 8119

Answers (1)

celsowm
celsowm

Reputation: 404

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

Upvotes: 3

Related Questions