我怎么能只允许privledged用户下载使用PHP中的PDF文件? [英] How can I allow only privledged users to download a pdf with php?

查看:211
本文介绍了我怎么能只允许privledged用户下载使用PHP中的PDF文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以说我有一些PDF文件存储在我的服务器上,我只想让谁的付出获得一个人去下载一个特定的PDF格式。

Lets say I have some pdf files stored on my server and I only want to allow a person who's paid have access to download a particular pdf.

因此​​,对于一个例子,比方说我有一大堆的电子书籍。用户将能够下载电子书A中的唯一方法是,如果他的帐户包含针对特定图书的权利凭证。

So for an example, let's say I have a bunch of e-books. The only way a user would be able to download e-book A is if his account contains the right credentials for that particular book.

什么是实现这一目标的最好方法是什么?

What's the best way to accomplish this?

任何意见/建议,关于如何提高我的想法是极大的AP preciated!

Any ideas/advice on how to improve my idea are greatly appreciated!

我目前的想法:

  • 一个用户下订单

  • A user places an order

成功时,一个新的文件夹会 通过创建自己的 / ACCOUNT_NUM / ORDER_ID / A的副本 特定文件将被存储在 这个目录

Upon success, a new folder would be created by their /account_num/order_id/ A copy of the particular file would be stored in this directory

推荐答案

下面存放的文档根的PDF文件。当有人想下载说,A.pdf,引导他们到PHP页面,如:<?code>的download.php文件= A.pdf 。编写的download.php页,检查请求用户的权限,并强制下载A.pdf的,如果他们的权限不够好。

Store the PDFs below the document root. When someone wants to download say, A.pdf, direct them to a PHP page like: download.php?file=A.pdf. Write that download.php page to check the requesting user's privileges, and force a download of A.pdf if their privileges are good enough.

这篇关于我怎么能只允许privledged用户下载使用PHP中的PDF文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆