PDA

View Full Version : Download File For Payment Security


JoeP
03-09-2005, 07:24 PM
I want to be able to download a PDF copy of a book we’re selling on the web site. Where can I research techniques, to set this up? I.E., buy the book via PayPal, and then have it available for instant download.

Any suggestions to a site that leads one through this?

TIA

JamieR
03-13-2005, 12:29 PM
What so you want only the paying customers to be able to download the book ye? I would utilize a php login script to authorize people who would have access to it before being able to download it. Also, I would change the location of the pdf reguarly and protect the directory using .htaccess or something.

Another way would be to use .htaccess to password protect the directory it is in and the actual file.

Jamie.

JoeP
03-13-2005, 03:57 PM
Thank you.

schleppel
03-13-2005, 04:30 PM
EDIT: This post is only useful if you are able to use php, i thought i was in the php forum, sorry.

From php.net/header (http://php.net/header)

<?php
// We'll be outputting a PDF
header('Content-type: application/pdf');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');

// The PDF source is in original.pdf
readfile('original.pdf');
?>
Then, all you would need is some kind of login system. Personally, i would use sessions and only allow the page to load if the user had a valid session.

To secure the original.pdf, either put it outside the document root or use a .htaccess file to protect it. Somehting like this in the .htaccess file:

<FilesMatch original.pdf>
Order deny,allow
Allow from localhost
</FilesMatch>
The .htaccess code is not tested an may not work.

JoeP
03-13-2005, 05:07 PM
Great! Thanks.