/    Sign up×
Community /Pin to ProfileBookmark

PHP Password Protect File (pdf link)

Please, Need help password protect any link to a file download. (pdf’s)

Need a simple php for my pdf file links!!!

CODE:
<div class=”box_1″>
<a href=”QRG/nurit2085.pdf”><img alt=”” class=”pic_left” src=”images/Machines/page3_pic1.png” width=”60″ height=”51″ /></a><a href=”QRG/nurit2085.pdf”><strong>NURIT 2085</strong></a> </div>

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@YelgnidrocJan 02.2011 — I'd have a login.

Once logged in then display the links that you require. Store the pdf's either in a database or outside of the web root directory.
Copy linkTweet thisAlerts:
@Slimpick404authorJan 02.2011 — Yelgnidroc, thanks for the advice, found a user log/pass script. Works fine. Thanks
Copy linkTweet thisAlerts:
@YelgnidrocJan 02.2011 — Bear in mind though that the document could be accessed directly, circumventing your login by doing:

www.yourwebsite.com/QRG/nurit2085.pdf
Copy linkTweet thisAlerts:
@eval_BadCode_Jan 02.2011 — I had the same problem. I ended up storing it in mySQL ? worked perfectly, but you'll have to configure the max packet size most likely.

I suppose you could have PHP encrypt the file with a symmetric key, probably equally as difficult to manage as a developer.

You could also protect them by switching the directories with nonces, and hiding the file below your webroot then making copies to directories like this

cp ~html/../../pdf/nurit07.pdf ~/html/0003281231/01023815121/12318131231/nurit07.pdf

then having the link send you to a page with a token/redirection and remove the directory structure after it's downloaded.
Copy linkTweet thisAlerts:
@criterion9Jan 02.2011 — Alternatively (as was suggested already) you can store the pdf outside of the document root and feed it back to the client using php. This will prevent direct linking and you can verify that the user has logged in already before sending the pdf contents.
×

Success!

Help @Slimpick404 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...