/**
  * Creates a new UploadFortythree model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new UploadFortythree();
     if ($model->load(Yii::$app->request->post())) {
         $uploadFile = UploadedFile::getInstance($model, 'file');
         if (!$uploadFile) {
             return $this->render('create', ['model' => $model]);
         }
         $hos = '-';
         $hospcode = explode("_", $uploadFile->baseName);
         if (strtoupper($hospcode[1]) === 'F43') {
             $hos = $hospcode[2];
         } else {
             $hos = $hospcode[1];
         }
         $model->hospcode = $hos;
         $filename = $uploadFile->baseName . "." . $uploadFile->extension;
         $model->file_name = $filename;
         $model->file_size = strval(number_format($uploadFile->size / (1024 * 1024), 3));
         $model->note1 = $uploadFile->baseName;
         $model->note2 = 'รอการนำเข้า';
         $model->save();
         $path = './fortythree/';
         $pathbackup = './fortythreebackup/';
         $uploadFile->saveAs($path . $filename);
         copy($path . $filename, $pathbackup . $filename);
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new UploadFortythree model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     //set_time_limit(0);
     //ini_set('max_execution_time', 1800);//ตั้งค่า php.ini
     //ini_set('post_max_size', '64M');
     //ini_set('upload_max_filesize', '64M');
     $model = new UploadFortythree();
     if ($model->load(Yii::$app->request->post())) {
         $upfile = UploadedFile::getInstance($model, 'file');
         if (!$upfile) {
             return $this->render('create', ['model' => $model]);
         }
         $hos = '-';
         $hospcode = explode("_", $upfile->baseName);
         if (strtoupper($hospcode[1]) === 'F43') {
             $hos = $hospcode[2];
         } else {
             $hos = $hospcode[1];
         }
         $model->hospcode = $hos;
         $newname = $upfile->baseName . "." . $upfile->extension;
         $model->file_name = $newname;
         $model->file_size = strval(number_format($upfile->size / (1024 * 1024), 3));
         $model->note1 = $upfile->baseName;
         $model->note2 = 'รอนำเข้า';
         $model->save();
         $path = './fortythree/';
         $pathbackup = './fortythreebackup/';
         $upfile->saveAs($path . $newname);
         copy($path . $newname, $pathbackup . $newname);
         $ubuntu_path = "/var/lib/mysql/fortythree/";
         if (strncasecmp(PHP_OS, 'WIN', 3) !== 0) {
             //copy($path . $newname, $ubuntu_path . $newname);
         }
         return $this->redirect(['view', 'id' => $model->id]);
         //}
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }