Question:
How to create Dynamic Download Link with PHP?
?
2012-05-10 22:55:31 UTC
I am trying to protect my ebooks. How can I make a link that changes or is unique to each user?

I want only the people that pay for the ebook to get it. Thanks
Four answers:
kashyff
2012-05-10 23:28:30 UTC
Do not paste download link directly, insteaddo as following:

After receiving payment

Create a simple link that lead to downloadfile.php

in download file.php

check for cookie to validate a user

if cookie is found(user validated) then throw content of file as downloadable content using headers as following:



header('Content-Description: File Transfer');

header('Content-Type: application/octet-stream');

header('Content-Disposition: attachment; filename='.basename($file));

header('Content-Transfer-Encoding: binary');

header('Expires: 0');

header('Cache-Control: must-revalidate, post-check=0, pre-check=0');

header('Pragma: public');

header('Content-Length: ' . filesize($file));

flush();

readfile($file);

exit;

hope that helps:
Jhon Williams
2012-05-11 00:14:13 UTC
store the path to the file in a database, along with a unique identifier and a timestamp of expiry. Then when a user accesses a link with the unique ID in the get variables, check the timestamp and fetch the file/display an error accordingly.
2016-02-22 02:53:59 UTC
Really, this is not something that can be answered in the context of a Yahoo Answers Space. But your best bet is using a CMS (content managment system). I would take a look at something like drupal. Drupal has tons of tutorials on their website, and you might find a drupal module that does what you want. You are going to be looking at putting at least a couple weeks into getting familiar with servers, the terminology, and the CMS.
?
2014-08-19 22:17:45 UTC
you can try this script Simple PHP and Jquery file download script

http://www.kythuatmang.net/php-jquery-file-download-script.php


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...