php - Allow a user to download a file after submitting their email address -


I want to allow users to download a file, but to do so, they have to provide an email address when they If you enter your address, a link / code is emailed to them, then they have to click the link and download the file.

My question is how can I restrict access to this 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 gives the user against the list of legitimate people, but I do not know how to access the file through a full address Stop

I can think of two methods:

  1. ".htaccess" Use (HTTP) authentication, keeping the password inside the protected directory.
  2. Using PHP Client to read in the file, hold the actual file out of the document ratios and output it to the client (but only if there is a valid code) supply (to produce a content-type header Do not forget to!).

Comments