W
W
warcevil2016-12-03 13:57:38
Yii
warcevil, 2016-12-03 13:57:38

How to add multiple pictures to a post?

Can you please tell me how can I attach several pictures to the news? What will be the structure of the database? And how is it generally better to implement an admin panel so that the user can easily choose photos from himself and immediately upload them to the news? What tools can...

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry, 2016-12-03
@slo_nik

Good afternoon.
I would make a separate table for images, separately for news and a link table where the id of the news and images will be stored.
How to upload multiple files you will find here
This article will also help you.
ps Working with linked data

A
Andrew, 2016-12-03
@mhthnz

HasMany for news and hasOne for pictures:
News table:
id
name
text
.....
Images table:
id
filename
news_id
.....

M
Maxim Timofeev, 2016-12-04
@webinar

In pursuit of slo_nik and Andrey , I can give 1 more option, store them in json in one cell in the news table. In general, this is not very correct, but if the number of pictures for the news is somehow limited and there cannot be a dozen, a hundred, etc. That might be a viable method.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question