Page 1 of 1

secure file downloads

Posted: Tue Aug 10, 2004 8:59 am
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

Posted: Tue Aug 10, 2004 9:41 am
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