문제

I was writing code for YIi, fileuploading.

When I write this:

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

$model->album_photocover->saveAs($path . '/' . $model->album_photocover);

it works.

     CUploadedFile::getInstance($model, 'album_photocover')->saveAs($path . '/' . $model->album_photocover);

But not the below one. Its only same code but written in one line. I hope you got it simply.

도움이 되었습니까?

해결책

In your "one-line-solution", when you valorize $model->album_photocover that you use to compose the save path?

CUploadedFile::getInstance($model, 'album_photocover')
       ->saveAs($path . '/' . $model->album_photocover);
//____________________________^++++++++++++++++++++++^

ADD I seen now @Telvin Nguyen comment, yep, that's the problem!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top