Exemplo n.º 1
0
 /**
  * Creates a new Special model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $fileName = 'file';
     $model = new Special();
     if (isset($_FILES[$fileName])) {
         //return var_dump($_POST);
         $imgs = \yii\web\UploadedFile::getInstancesByName($fileName);
         $img = $imgs[0];
         $mysqlName = time() . '_' . $img->name;
         $url = getcwd() . '/src/special/' . $mysqlName;
         $kaboom = explode(".", $img->tempName);
         // Split file name into an array using the dot
         $fileExt = end($kaboom);
         // Now target the last array element to get the file extension
         self::ak_img_resize($img->tempName, $url, 1024, 683, $fileExt);
         chmod($url, 0755);
         $model->photo_url = $mysqlName;
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }