/** * Upload attachment for Meeting * @param int $id * @return mixed */ public function actionUploadmeeting($id) { $id = (int) $id; $model1 = new MeetingAttachments(); if ($model1->load(Yii::$app->request->post())) { //If request is post $model1->path = UploadedFile::getInstances($model1, 'path'); foreach ($model1->path as $files) { $filesize = $files->size; if ($files->saveAs('uploads/' . $files->baseName . '.' . $files->extension)) { $model1->congress_id = $id; $path = "uploads/" . $files->name; $filetype = $files->extension; $cong = MeetingDetails::find()->where(['id' => $id])->one(); $congressid = $cong['congress_id']; Yii::$app->db->createCommand("insert into meeting_attachments(meeting_id,path,congress_id,size,type)values('{$id}','{$path}','{$congressid}',' {$filesize}','{$filetype}')")->execute(); } } return $this->redirect(array("meeting/update", 'id' => $id)); } }