Getting error finfo_file(C:\xampp\tmp\php29C.tmp): failed to open stream: No such file or directory while uploading multiple files.
tried inserting $model->save(); before saveAs() but then it upload only one file not all files, also not getting path in database for each file which is getting uploaded.
Controller:
public function actionCreate()
{
$model = new RoomTypes();
if ($model->load(Yii::$app->request->post()))
{
$imageName = $model->room_type;
$model->file = UploadedFile::getInstances($model, 'file');
foreach ($model->file as $file_instance)
{
$model->save();
$file_instance->saveAs('uploads/room_img/' . $file_instance->baseName . '.' . $file_instance->extension);
//save the path in the db column
$file_instance->$model->images = 'uploads/room_img/'.$imageName.'.'.$file_instance->extension;
return $this->redirect(['view', 'id' => $model->id]);
}
}
else
{
return $this->render('create',
[
'model' => $model,
]);
}
}
$file_instance->$model->imagesis not meaningful.