Answer the question
In order to leave comments, you need to log in
How to attach a multiple image to the material on the site?
Tell me how best to organize the attachment of multiple images to an object?
There is an article object to which any number of images is attached via file imput / multiple.
I upload it to the server like this:
public function upload()
{
if ($this->validate()) {
foreach ($this->imageFiles as $file) {
$file->saveAs('uploads/' . $file->baseName . '.' . $file->extension);
$files[] = $file->baseName . '.' . $file->extension; // Пока что, просто для получения массива имён
}
return $files;
} else {
return false;
}
}
Answer the question
In order to leave comments, you need to log in
Good evening.
Create a separate table, link by material id.
Also create a separate controller and model for images, a separate crud.
Although it's how you like it.
Images that belong to a particular material can be displayed using the gridview on the material view page (in the admin).
PS Or use a visual editor like ckeditor for this purpose. Images are placed directly in the content of the material, it is convenient to edit, do not bother with downloading.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question