[英]storing pdf files on server securely
I am deploying a website from where user can purchase the pdfs. 我正在部署一个网站,用户可以从该网站购买pdf。 now i am searching for the way for storing the pdfs
so that it only can be downloaded when payment is done. 现在,我正在寻找存储pdfs
的方法,以便仅在付款后才能下载。 I have came across one way in which i can store the pdfs in to the Mysql
database and generate the path to it when required credentials fulfill. 我遇到了一种方法,可以将pdfs存储到Mysql
数据库中,并在满足所需凭据时生成到它的路径。
Is there any other way to do this and link to the pdf file should be dynamic and encrypted so that other links to the other books can't be predicted. 还有其他方法可以做到,指向pdf文件的链接应该是动态的和加密的,以便无法预测到其他书籍的其他链接。
and the server side language I am using is PHP
我使用的服务器端语言是PHP
I would : 我会 :
Deny any access to the files -- ie use a .htaccess file (That way, no-one has access to the file) 拒绝对文件的任何访问-即使用.htaccess文件(这样,没有人可以访问该文件)
Develop a PHP script that would : 开发一个PHP脚本,该脚本将:
The advantage is that your PHP script has access to the DB -- which means it can allow users to log-in, log-out, it can use sessions, ... 优点是您的PHP脚本可以访问数据库-这意味着它可以允许用户登录,注销,可以使用会话,...
Here is another answer from a stack user that fits this problem: Creating a Secure File Hosting Server for PDFs 这是适合该问题的堆栈用户的另一个答案: 为PDF创建安全文件托管服务器
is there any other way to do this and link to the pdf file should be dynamic and encrypted so that other links to the other books can't be predicted. 还有其他方法可以做到这一点,并且指向pdf文件的链接应该是动态的和加密的,以便无法预测到其他书籍的其他链接。
I hope this code helps 我希望这段代码对您有所帮助
<?php
// We'll be outputting a PDF
header('Content-type: application/pdf');
// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');
// The PDF source is in original.pdf
readfile('original.pdf');
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.