php - Let users download files that are not in a web directory? -


possible duplicate:
allow users download files outside webroot

hi guys want use php allow users download files directory on server not part of "web" files...is there way this?

e.g.

my web files in /www/bla/bla

but files want downloaded in /home/bla/bla

what this:

$file = '/home/bla/bla/file.ext';      header('content-description: file transfer'); header('content-type: application/octet-stream'); header('content-disposition: attachment; filename='.basename($file)); header('content-transfer-encoding: binary'); header('expires: 0'); header('cache-control: must-revalidate'); header('pragma: public'); header('content-length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; 

readfile() retrieves content of file , prints this. rest of code force download.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -