0

I am planning to do a web-app that will control the download to users. To prevent users from directly accessing the file, what I can do a htaccess to prevent downloading the files. But my question now is how to access it.

What I am thinking is access the file via server path and place the file in the server temp then generate a link to download it. The question is, how to do this? Also, if there are other easier methods on doing this.

I am using CI btw.

Thanks.

Mr A
  • 1,345
  • 4
  • 22
  • 51
  • possible duplicate of [restricting file download in PHP](http://stackoverflow.com/questions/8264164/restricting-file-download-in-php) or http://stackoverflow.com/questions/3858018/control-access-to-files-available-for-download – deceze May 02 '12 at 06:04

1 Answers1

2
  1. Place the files outside the webroot, so they're not accessible via the web server.
  2. Create a PHP script that a user can access that will read the file from disk and output it to the user, see readfile.
  3. Implement any kind of authentication/authorization mechanism in that file that you want.
deceze
  • 510,633
  • 85
  • 743
  • 889