Page 1 of 1

php script to download pdf files

Posted: Mon Oct 03, 2011 2:20 pm
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

Re: php script to download pdf files

Posted: Mon Oct 03, 2011 3:41 pm
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.

Re: php script to download pdf files

Posted: Mon Oct 03, 2011 3:58 pm
by djdavedawson
This worked great !

Is doing this an accepted practice?

Thanks Again !!

Re: php script to download pdf files

Posted: Mon Oct 03, 2011 9:56 pm
by flying_circus
Sure, I put everything I can outside of the document root.