Domanda

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.

È stato utile?

Soluzione

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!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top