protected function findModel($id)
{
if (($model = Article::findOne($id)) !== null) {
return $model;
} else
throw new NotFoundHttpException('The requested page does not exist.');
}
public function actionSetImage($id)
{
$model = new ImageUpload;
if(Yii::$app->request->isPost)
{
$article = $this->findModel($id);
// var_dump($article->title);die;
$file = UploadedFile::getInstance($model, 'image');
$model->uploadedFile($file);
// var_dump(strtolower(md5(uniqid($file->baseName)) . '.' . $file->extension));
// $article->saveImage( $model->uploadedFile($file));
}
return $this->render('image', ['model'=>$model]);
}
}