我希望仅在有人使用注册表单(提交后)时才能够限制下载访问。无法通过复制/粘贴或发布的链接访问 HTML/PHP。
这是我到目前为止所拥有的: 服务器:服务器上的“下载”文件夹有一个 .htaccess 文件
<Files download.pdf>
order deny,allow
deny from all
</Files>
网站:在表单上,提交后有一个 PHP 联系人表单处理程序,它将注册信息发送到电子邮件地址并重定向到“谢谢您 - 这是您的下载 html 页面”。我已在此 html 页面上添加
<META http-equiv="refresh" content="1;URL=http://www.pathtofilehere/signupform.php">
<a rel="nofollow" href="http://www.pathtofilehere/signupform.php"> Get Your Download Now!</a>
“Thank You - Here's Your Download”页面会提示自动下载 PHP。
<?php
$filename = "download.pdf";
if(ini_get('zlib.output_compression'))ini_set('zli b.output_compression', 'Off');
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));
readfile("$filename");
exit();
?>
我在测试服务器上,因此无法将“下载”移出根目录。设置完成后,我会将其移出根目录。还有一个问题……网站的所有者没有设置数据库。因此,此时登录不起作用。同时...
我想要发生的事情:只有在表格“提交”后才能下载。现在,我可以通过 html 页面访问下载。或 PHP 页面。我在论坛上尝试了Gateway PHP --> Protected File PHP,但无法正常工作。我可以设置某种参数 session 来传递以使其仅对“已注册”人员可见/可访问吗?
非常感谢。