[Not Solved] Help for image upload

Hello everybody,

I have an error with CUploadedFile, I can’t use it !


 $model->avatarPath=CUploadedFile::getInstance($model,'avatarPath');

                 

if($model->avatarPath->getHasError()) {

            echo 'error';

            exit();

        }

I have this error :

Why I can’t call getHasError() ?!? Normaly CUploadedFile was copy in $model->avatarPath

why you set $model->avatarPath=CUploadedFile::getInst… … ?

you can refer This wiki article

I already read this article.

I used this article: http://www.yiiframework.com/wiki/2/how-to-upload-a-file-using-a-model/

But the problem remains the same: I can not use methods CUploadedFile

It looks like CUploadedFile::getInstance is not returning the right object.