S
S
Sergey2016-02-15 19:40:17
Yii
Sergey, 2016-02-15 19:40:17

Why is there an error when uploading two pictures?

I tried to organize the loading of two pictures from two fields figuratively like this

// form
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>

    <?= $form->field($model, 'logo')->fileInput([ 'accept' => 'image/*']) ?>
    
    <?= $form->field($model, 'footer')->fileInput([ 'accept' => 'image/*']) ?>

    <button>Submit</button>

<?php ActiveForm::end() ?>

// controller
<?php
$model->logo = UploadedFile::getInstance($model, 'logo');
$model->footer = UploadedFile::getInstance($model, 'footer');
if ($model->logo && $model->validate()) {
                $model->logo->saveAs(Yii::getAlias('@frontend/web/').'/foto/' . $model->logo->baseName . '.' . $model->logo->extension);}
            if($model->footer && $model->validate()){
                $model->footer->saveAs(Yii::getAlias('@frontend/web/').'/foto/' . $model->footer->baseName . '.' . $model->footer->extension);}

$model->save();
The database is saved in a folder no, why don't you tell me?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey, 2016-02-15
@VladimirAndreev

what does the error log say?

N
nepster-web, 2016-02-15
@nepster-web

Perhaps there are no rights or the path is wrong.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question