Illegal offset type in isset or empty

Current PHP version: 7.1.7

please help me I have this problem

Illegal offset type in isset or empty at line 113

I have this problem after I decided to upload files to my website

in C:\xampp\htdocs\archive\vendor\yiisoft\yii2\web\UploadedFile.php line 113:

 public static function getInstanceByName($name)
{
    $files = self::loadFiles();
    return isset($files[$name]) ? new static($files[$name]) : null;
}

and guys if this not clear ask me for more explication and thanks

This code in models

[['file'],'file'],

this code in _form

    <?= $form->field($model,'file')->fileinput(); ?>

in first I used getInstance() but replecd getInstanceByName() because had porblem here

error yii2 upload Call to a member function saveAs() on null

Upvotes: 1

Views: 4807

Answers (2)

in first I used $model->file = UploadedFile::getinstancebyname($model,'file');

but right is to use $model->file = UploadedFile::getinstance($model,'file');

Upvotes: 0

Harlan Gray
Harlan Gray

Reputation: 341

Illegal offset type errors occur when you attempt to access an array index using an object or an array as the index key.

You function is defined as getInstanceByName($name), but you are calling it using getinstancebyname($model,'file')

Something wrong there

Upvotes: 2

Related Questions