/**
  * Creates a new RramatDocfiles model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (Yii::$app->request->isAjax && Yii::$app->request->isPost) {
         $UploadFile = new UploadDocFile();
         $UploadFile->docFile = UploadedFile::getInstance($UploadFile, 'docFile');
         $UploadTrigger = $UploadFile->upload();
         if ($UploadTrigger['success']) {
             $Docfiles = new Docfiles();
             $Docfiles->docfiles_hash = $UploadTrigger['savedhashfilename_utf8'];
             $Docfiles->docfiles_name = $UploadTrigger['savedfilename'];
             $Docfiles->docfiles_ext = $UploadTrigger['fileextension'];
             if ($Docfiles->save()) {
                 $RramatDocfiles = new RramatDocfiles();
                 $RramatDocfiles->id_docfiles = $Docfiles->primaryKey;
                 $RramatDocfiles->id_recoveryrecieveaktmat = $_POST['id_recoveryrecieveaktmat'];
                 if ($RramatDocfiles->save()) {
                     echo json_encode(['ok']);
                 } else {
                     throw new HttpException(500, Proc::ActiveRecordErrorsToString($RramatDocfiles));
                 }
             } else {
                 throw new HttpException(500, Proc::ActiveRecordErrorsToString($Docfiles));
             }
         } else {
             throw new HttpException(500, 'Ошибка при загрузке файла');
         }
     } else {
         throw new HttpException(500, 'Ошибка запроса');
     }
 }
Example #2
0
 /**
  * Creates a new Docfiles model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (Yii::$app->request->isAjax && Yii::$app->request->isPost) {
         $model = new UploadDocFile();
         $model->docFile = UploadedFile::getInstance($model, 'docFile');
         $UploadTrigger = $model->upload();
         if ($UploadTrigger['success']) {
             $Docfiles = new Docfiles();
             $Docfiles->docfiles_hash = $UploadTrigger['savedhashfilename_utf8'];
             $Docfiles->docfiles_name = $UploadTrigger['savedfilename'];
             $Docfiles->docfiles_ext = $UploadTrigger['fileextension'];
             if ($Docfiles->save()) {
                 echo json_encode(['ok']);
             } else {
                 throw new HttpException(500, Proc::ActiveRecordErrorsToString($Docfiles));
             }
         } else {
             throw new HttpException(500, Proc::ActiveRecordErrorsToString($UploadTrigger['errors']));
         }
     } else {
         throw new HttpException(500, 'Ошибка запроса');
     }
 }