Answer the question
In order to leave comments, you need to log in
Do I understand correctly the essence of uploading images to products?
Hello, yiisty)
I'm learning yii2, faced with the task of uploading photos for products.
There are 2 tables (exaggerated):
`product` - id | name (ID and product name)
`product_photo` - id | product_id | image (post ID, product ID, image link)
The question is how to attach uploaded photos to a product? I present so far as follows:
In the Product.php product model, add the $images property. When displaying a product model (editing in the admin panel) - display an additional input for multiple uploads:
<?= $form->field($model, 'images[]')->fileInput(['multiple' => true, 'accept' => 'image/*']) ?>
Answer the question
In order to leave comments, you need to log in
Good morning.
Basically correct.
First, do as you described.
It will work - look for a more elegant solution.
And you can share.
First, create a record in the product database, then, after you are redirected to the page for viewing the created product, attach images. Just add a form to upload images on the product view page.
There are many options, choose the one you like best.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question