title: How to let only authorized user access to some files?
body: <p>Here is the situation:
  I have an Apache server , which hosting a php program, the program allow user to login and the user can upload files, and share their upload files to others, so, I have a folder called "attachment" in the htdoc folders, which is store the user's attachement.  But I don't want people get access to this folder directly, I only let some users(base on their user right), to get the file they want, others, can get access to that file...</p>
  
  <p>For example, A upload file_a, and share with B, C. User B, C can dl the link via a link, but User D even he/she got the link, but he/she still can't download, even he/she is logging or not. How can I do this checking? Thank you.</p>