Open gorsargsyan opened 9 years ago
$model->image = \yii\web\UploadedFile::getInstances($model, 'image');
нужно прописать, и будет работать
`public function actionUpdate($id) { $model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$model->image = UploadedFile::getInstances($model, 'image');
foreach ($model->image as $item) {
$path = Yii::getAlias('@webroot/upload/files/') . $item->baseName . '.' . $item->extension;
$item->saveAs($path);
$model->attachImage($path);
}
return $this->redirect($url = Url::previous());
} else {
return $this->render('update', [
'model' => $model,
]);
}
}`
// Controller
public function actionUpdate($id) { $model = $this->findModel($id);
//view _form
<?= $form->field($model, 'image[]')->fileInput(['multiple' => true, 'accept' => 'uploads/*']) ?>