V
V
Vadim2017-02-08 14:00:09
PHP
Vadim, 2017-02-08 14:00:09

How to organize access to images for authorized users?

There is a site in PHP, where for each user you need to organize work with your own set of images. In the course of work, users can insert images into texts, i.e. for the frontend, these should be regular urls. Actually, the task is that each user has his own set of images.
What solutions do I see:
1) Generate directories for users with long random names (hashes) and don't sweat it.
Pros: very simple implementation
Cons: having learned the name of the directory of any user, anyone (even a completely outsider unauthorized user) can access other people's images
2) In the same way, generate random directory names, but in fact store images in directories whose name does not shine outside, redirect requests by url with a hash to the script where the user's rights are checked, and if ok, then the file with the image is read and given client.
Pros: you can organize any checks
Cons: too many operations for each request, which increases the load
Maybe there are some other options how to solve the problem? I have no more ideas

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita, 2017-02-08
@Rema1ns

Cons: too many operations for each call, which increases the load - it's too much when there are hundreds of thousands of iterations. Use option 2, it's more popular

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question