X
X
x222_try2015-04-23 13:17:27
MySQL
x222_try, 2015-04-23 13:17:27

How to store image paths?

How to store image paths in mysql database? Use separate fields or all in one separated by commas?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
J
Jonh Doe, 2015-04-23
@x222_try

I would do so.
FILES_TABLE - table
id, filename, filepath
i.e. three "columns" each responsible for his own.
and each line has one picture.

K
kompi, 2015-04-23
@kompi

We do not want duplicate string values ​​in one table, so this is how:
Table 1: file_id, path
Table 2: id, file_id, title, description, ...
Accordingly, file_id is a foreign key.
PS This applies to all identical file resources.

A
avada kedavra, 2015-04-23
@kedavra

The question is not specific.
If all the pictures are in one folder, it is enough to store the file name, and in the script do the concatenation of the path + name from the database.
If there is a need to store images from different directories in one table, it is worth asking if the database is designed correctly.
Sometimes you don't need to store the path at all, you can compose the path as id.'/avatar.jpg'.

A
AdvanTiSS, 2015-04-23
@AdvanTiSS

two tables
FILE (id, file_name, file_path_id)
FILE_PATH (id, file_path)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question