M
M
mynewvk2014-06-29 22:41:59
PHP
mynewvk, 2014-06-29 22:41:59

What is the best way to store user photos?

I have a site where users can upload their photos, after uploading I make several images from the photo: "photo - original", "photo 300px wide", "square photo" and so on. Before that, it was stored in the img folder, in which there were a couple more folders for different sizes, and photos of all users were uploaded there. Then I read that if there are a lot of photos, the server will slow down. An idea came up: after registration, create a couple of folders for each user specifically for his images. What do you advise? What is the best way to organize all this?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
vsevolod0812, 2014-06-30
@mynewvk

1. You create an array of servers where the photos will be stored
2. You throw a handler for each
3. In the database you store only the path to the folder with the file, for example, like this v311524358/9fc3/Jlgxdu1LABI.jpg and also save the server number.
4. When displaying a photo, you look at the server number, take its path and add the address to the file.
I've done it this way, it's very convenient.

S
samodroid, 2014-06-30
@samodroid

Each user needs their own folder for pictures.

V
Vitaly Zheltyakov, 2014-06-30
@VitaZheltyakov

"Then I read that if there are a lot of photos, the server will slow down."
- It will slow down when sorting through files, and there will be no brakes with direct access.
The quickest and easiest option is to name the files according to id_user, id_album and id_photo. And then access the file directly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question