The goal is after people paid (PayPal or Stripe), they land on a download page.

You upload the file to /uploads for example. You can deny access to the dir with .htaccess.

I suppose if I then create a link /uploads/product, that a client can download it.

But that link can now be shared all over the internet.

What would be the best way to go about it?

I want to code it myself in PHP & JS if required.


Rough idea:

  • create a temporary download file. Use a random file name.
  • create a program that will download the file. The program should delete the temporary download after a click on the download file link by the client
  • send the download page (not the download file) link to the user, with a parameter that is the download file.

You could put some 'downloaded ok?' location on the download page, then delete the temp file afterwards.

| improve this answer | |
  • Would it make things easier if the client had a WordPress user account? – progonkpa Sep 24 at 10:39
  • Don't think that would make a difference. Assuming that the person completed the 'order' process, then the above psuedocode would work just fine. Only the person would get the link (after order payment/whatever), and it's a unique link - once someone used the link to get the file, the unique file (related to the link) is deleted. Anyone else with the link wouldn't get the file - you deleted it. – Rick Hellewell Sep 24 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.