Answer the question
In order to leave comments, you need to log in
How to upload multiple images in one post?
Here is the form. She is simple. I just need to upload all the images to the uploads root folder and so that their address remains in the database:
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'text')->textarea(['rows' => 6]) ?>
<?= $form->field($model, 'url')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'status')->dropDownList(['Черновик','Публикация']) ?>
<?= $form->field($model, 'sort')->textInput() ?>
<?= $form->field($model, 'date_added')->textInput() ?>
<?= $form->field($model, 'main_img')->fileInput(['maxlength' => true]) ?>
<?= $form->field($model, 'first_img')->fileInput(['maxlength' => true]) ?>
<?= $form->field($model, 'sec_img')->fileInput(['maxlength' => true]) ?>
<?= $form->field($model, 'third_img')->fileInput(['maxlength' => true]) ?>
<?= $form->field($model, 'fou_img')->fileInput(['maxlength' => true]) ?>
<?= $form->field($model, 'fiv_img')->fileInput(['maxlength' => true]) ?>
<?= $form->field($model, 'six_img')->fileInput(['maxlength' => true]) ?>
<?= $form->field($model, 'sev_img')->fileInput(['maxlength' => true]) ?>
<?= $form->field($model, 'eag_img')->fileInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
Answer the question
In order to leave comments, you need to log in
Everything is in the docks: https://www.yiiframework.com/doc/guide/2.0/en/inpu...
YouTube has a lot of videos on uploading files to youtube
Yes, and everything is the same in essence as with one, sometimes there are nuances in the form: UploadedFile::getInstances
instead of UploadedFile::getInstance
the second method will return an object, the first array of objects. But in your form, all files have separate attributes, and not in one, so this will not affect you.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question