As a photographer, I have my own website with a portfolio and such. I also have a log-in system for users, where I give them access to their own private images (it displays all images placed inside a specific folder - I do this manually for each user).
When a user logs in and sees his private images, he'll notice the URL says the following (when he downloads it/clicks it/etc): www.mywebsite.com/FOLDER_NAME/IMG_123.jpg
By simply doing a bit of guessing, he'll be able to find other users private images. Of course this is defeats the purpose of having private images on my website, so I have to find a way around that.
At the moment, the user can only see his private images if his user_email (unique) matches userRow:
if ($userRow['user_email'] == "email@hotmail.com")
I'm not so sure what to search for. Restrict access to images wasn't a successful search query for me.
What can I do? I guess an option would be to call the folders something random, such as: "Charles661846Xkdfdsnf34590u". That will be hard to guess, but I'm not so sure about security (as in if there are other ways to get access to the root?).
I have taken a look at Deny direct access to all .php files except index.php but that is not what I want exactly.
What can I do in this case?
I've programmed my site in php,html and a bit javascript.