php script to download pdf files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
djdavedawson
Forum Newbie
Posts: 9
Joined: Tue Jul 29, 2008 10:13 am

php script to download pdf files

Post by djdavedawson »

I have a pdf directory where all the pdf's are chmod 640.

It's set this way so that people can't access the pdfs directly like this.

Example: www.mydomain.com/pdf/pdf.pdf

I have a php download script in the pdf directory to download the files, but it doesn't work with chmod 640.

I get the following error:

[function.fopen]: failed to open stream: Permission denied

I'm assuming i need the script to run as the owner or group but can't figure how to do it.

Any suggestions?

Thanks in advance.

~D
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: php script to download pdf files

Post by flying_circus »

why not place the pdf files outside the web root, so they cannot be directly accessed? Then you can assign the required permissions to stream the files with php.
djdavedawson
Forum Newbie
Posts: 9
Joined: Tue Jul 29, 2008 10:13 am

Re: php script to download pdf files

Post by djdavedawson »

This worked great !

Is doing this an accepted practice?

Thanks Again !!
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: php script to download pdf files

Post by flying_circus »

Sure, I put everything I can outside of the document root.
Post Reply