0

I only want the zip file to be available once after a user purchases it, and it can only be downloaded once

The file is outside public_html, it isn't publicly available, but I can't figure how to send the file to the browser.

Using this guide: Idiot-proof, cross-browser force download in PHP how can I get it to work with non-public access to the zip file? I tried setting the path to the file, but it didn't work. (I tested it with a browser accessible path and it did work)

As for the other concern, only allowing it to be downloaded once, I am doing the following:

  1. user accesses the unique download page
  2. checks to see if the product was already downloaded
  3. updates mySQL saying that it has been downloaded
  4. send headers to download the file
Community
  • 1
  • 1
user3023421
  • 333
  • 1
  • 7
  • 16
  • 1
    The interesting thing about code is that a description just isn't the same... ever. I can think of quite a few ways to address your intention, but absent any proffered code, cannot address your problem. –  May 21 '14 at 02:29
  • You can not be sure whether user in fact downloaded a file or not. Need to give some time for download attempts. – Deadooshka May 21 '14 at 04:59

1 Answers1

0

You can copy zip file to an specified location when user registers. The new name of zip file should be with username so that it can be unique. Once user has downloaded you can delete the file. As the file has been copied once in registration the copying process event wont occur again.

On registration :

copy($main_copy, "/download/balh_".$username.".zip");

Post download :

unlink("/download/balh_".$username.".zip");