E
E
Evgeny Rozanov2016-06-01 17:16:10
Yii
Evgeny Rozanov, 2016-06-01 17:16:10

Working with Yii files Where is the mistake?

Good afternoon. You need to access the file in the application. To do this, I need to upload it through the form. Created a form according to one of the guides on the official YiiFramework website.
Model

public $imageFile;

    public function rules()
    {
        return [
            );
$form->field($file, 'imageFile')->fileInput();

ActiveForm::end();

As a result, I get not a file upload form, but
Call to a member function formName() on a non-object

Searched many forums, so far nothing has helped!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey, 2016-06-01
@VladimirAndreev

$form->field($file, 'imageFile')->fileInput();
$file - exactly the yii\base\Model instance in the view?

S
Skrolea, 2016-06-01
@Skrolea

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

You should have $model there, not $file

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question