title: Access/Download server files, not in site root, with PHP
body: <p>Usually I save documents (images, mpegs, excel, word docs, etc...) for my friends or family on my website's root, inside a directory called /files/  or something similar.  Nothing too uncommon.</p>
  
  <p>But, I have been playing with user session control, and allowing users to upload files to the dedicated /files/ directory. (the file names are saved in a db, with that user's ID)</p>
  
  <p>But, that means other people could try to guess and locate other people's files.<br>
  I do randomize the file names, upon upload.  And I stop the apache from displaying the /files/ directory content.  </p>
  
  <p>However, I'd like to start saving the files outside of the website's root.  This way it can't be accessible via the browser.</p>
  
  <p>I don't have any code to show, but I didn't want to even start on this endeavor if it's not able to be accomplished.  I did find this snippet that shows how to display an image, from outside your website root:</p>
  
  
  
  <p>Maybe I can use this for any file type, but has anyone heard of a better way to allow users (logged in) to access their files from online, but not letting other users has similar access?</p>