Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In my experience you can best solve this by uploading your files to a directory that is not available publicly. Then you would also have some table in your database where you'd have at least three columns: the <em>name</em> of the file, the <em>access level</em> you want to give it and the <em>user</em> that uploaded the file. </p> <p>You could then write something that checks if the visiting user has access to the file. First it would retrieve the column containing information about the mentioned file. Based on that information, if the user has access, use <a href="http://php.net/readfile" rel="nofollow">readfile</a> (see the example on the PHP manual) to display the file. In all other case you could just show a 403 Forbidden page.</p> <p>In your case the function that checks access would look something like this:</p> <pre><code>function hasAccess($accesslevel, $owner, $visitor) { if ($accesslevel === 'public') { return true; } if ($accesslevel === 'private') { return $owner === $visitor; } if ($accesslevel === 'friends') { return $owner === $visitor || isfriend($visitor, $owner); } } </code></pre> <p>This is just an example, your implementation would probably be a little different, depending on your environment.</p> <p>As far as I know Facebook just allows all files to be viewed by everyone, but tries to create a url that is difficult to guess. As soon as you've got the url, you can just view the image itself, regardless of the privacy-settings of the user that uploaded the image.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload