How to create a digital product download link that can't be used twice?

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.

Topic uploads paypal plugin-development Wordpress

Category Web


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.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.