Can't upload multiple images in the form

Web Tips Q & ACategory: Krajee Yii2 ExtensionsCan't upload multiple images in the form
amir.ma asked 7 months ago

this what I’ve done in the form but when I want to brows for the second image it just gets overwrite on the previous one

<?= $form->field($model, 'image')->widget(FileInput::classname(), [
            'options'=>['accept'=>'image/*', 'multiple'=>true, ],
            'pluginOptions'=>[
            'allowedFileExtensions'=>['jpg','gif','png'],
            'overwriteInitial'=>false,
            ]
        ]);
    ?>
1 Answers
Mubat answered 6 months ago

Your should set attribute name as array:

<?= $form->field($model, 'image[]')->widget(FileInput::classname(), [
            'options'=>['accept'=>'image/*', 'multiple'=>true, ],
            'pluginOptions'=>[
            'allowedFileExtensions'=>['jpg','gif','png'],
            'overwriteInitial'=>false,
            ]
        ]);
    ?>

See Uploading Multiple Files

amir.ma replied 6 months ago

Thanks for ur answer but I’ve done this before , but because I couldn’t edit my question , it is left over like this, but it’s `images []` and it’s not still working

amir.ma replied 6 months ago

Thanks for ur answer but I’ve done this before , but because I couldn’t edit my question , it is left over like this, but it’s `images []` and it’s not still working

Login or register to contribute or comment.

Login   Register