允许用户在提交电子邮件地址后下载文件 [英] Allow a user to download a file after submitting their email address
问题描述
我想允许用户下载文件,但为了做到这一点,他们必须提供一个电子邮件地址。当他们输入他们的地址,一个链接/代码通过电子邮件发送给他们,然后他们必须单击该链接,该文件下载。
I want to allow users to download a file, but in order to do so they have to supply an email address. When they enter their address, a link/code is emailed to them, then they have to click that link, and the file downloads.
我的问题是 - 我如何限制访问该文件,以便只有具有有效代码的人才能下载?我了解如何创建一个代码,然后如何检查用户提交的代码对一个有效的代码,但我不知道如何通过它的绝对地址来阻止文件的访问。
My question is- how can I restrict access to the file so that only people with a valid code can download it? I understand how to create a code, and then how to check the code that the user submits against a list of valid ones, but I don't quite know how to stop the file from being accessable via it's absolute address.
推荐答案
我可以想到两种方法:
- 使用.htaccess(HTTP)身份验证,将文件保存在密码保护目录下。
- 将实际文件保存在DocumentRoot之外,使用PHP脚本读取文件并输出它到客户端(但只有提供有效的代码)(不要忘记输出Content-Type头!)。
这篇关于允许用户在提交电子邮件地址后下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!