I'm trying to deal with yii2 and made crud news on the manual, everything works. Now I’m trying to tie the image downloader to the news and don’t figure out how to correctly enter the code from the manual for uploading the file to the controller action:
public function actionCreate() { $model = new GoodsCatalog(); if (Yii::$app->request->isPost) { $model->imageFile = UploadedFile::getInstance($model, 'imageFile'); if ($model->upload()) { // file is uploaded successfully return; } } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', [ 'model' => $model, ]); } } I understand what is wrong, please tell me how to combine the code for downloading a file with an existing one?