asp-classic - 如何在 ASP 中引发 "File Download"并防止热链接

标签 asp-classic vbscript download

我有以下 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);

我第一次在asp中使用这个:

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

我也阻止“盗链”

最佳答案

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

关于asp-classic - 如何在 ASP 中引发 "File Download"并防止热链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5004190/

相关文章:

database - VBScript:从 Scripting.Dictionary 中排序项目

vbscript - 读取文本文件并显示在表 vbscript 中

firefox - 在 Firefox 浏览器中显示 csv

Javascript和ASP更优雅地创建动态文件夹

javascript - 将表格导出到 Excel,包括宏

scripting - 如何以编程方式更改工作站的 IP 地址?

postgresql - 如何使用 PowerShell 或 VBScript 将数据插入 Postgres 表中?

javascript - CSV 太大,无法通过 AJAX 处理

python - 在python中下载文件

java - 从 http 下载文件中检索文件名