secure file downloads

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
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

secure file downloads

Post by Coco »

Im fairly certain that this can be done, however, i have taken a look thru the manual and cant find anything for sending files to the browser, kinda the way you can use imagejpeg to send an image to the browser

what im after doing is collecting files from a secured directory and sending them to the user to download, without having the user login to said secure directory, or saving a 'temporary' copy in the non secure area. can anyone point me in the right direction?

ta muchly
ldomingues
Forum Commoner
Posts: 41
Joined: Fri Aug 06, 2004 1:15 pm
Location: Portugal

Post by ldomingues »

If i understand what you're asking, you want to grant access to files upon authentication.

alternative 1) don't store the files in the file system, but in a database table (not suitable for high download volume)
alternative 2) store the files in a directory off the webserver root, and send the files to the client using fpassthru
alternative 3) store the files in a directory in the webserver root and protect access to them using .htaccess file, and send the files to the client
using fpassthru

Take a look: http://pt2.php.net/manual/en/function.fpassthru.php
Post Reply