/**
  * Creates a new AttachedFiles model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new AttachedFiles();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'request_id' => $model->request_id, 'url' => $model->url]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Beispiel #2
0
 public function upload()
 {
     foreach ($this->requestFile as $file) {
         $this->fileNameAttached = uniqid() . '.' . $file->extension;
         $file->saveAs('files/' . $this->fileNameAttached);
         $attachedFiles = new AttachedFiles();
         $attachedFiles->request_id = $this->id;
         $attachedFiles->url = $this->fileNameAttached;
         $attachedFiles->save();
     }
 }