/**
  * Creates a new TravellerPhoto model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new TravellerPhoto();
     $uploadModel = new UploadImagesForm();
     $traveller_id = isset($_GET['traveller_id']) ? $_GET['traveller_id'] : 0;
     $traveldescription = TravellerDescription::find()->where(['traveller_id' => $traveller_id])->one();
     if ($uploadModel->load(Yii::$app->request->post()) && $model->load(Yii::$app->request->post())) {
         $traveller = Travellers::findOne($traveller_id);
         $uploadImagePath = Yii::$app->basePath . "/../profiles/travellers/";
         $img = str_replace(' ', '+', str_replace('data:image/png;base64,', '', $uploadModel->uploadFiles));
         $data = base64_decode($img);
         $filename = uniqid() . '.png';
         $file = $uploadImagePath . $filename;
         if (!is_dir($uploadImagePath)) {
             mkdir($uploadImagePath);
         }
         $success = file_put_contents($file, $data);
         if ($success) {
             $orignalname = $filename;
             $manupolated_name = md5(uniqid()) . '.png';
             $modelAttachments = new Attachments();
             $modelAttachments->user_id = $traveller->user - _id;
             $modelAttachments->orignal_name = $orignalname;
             $modelAttachments->manupulated_name = $manupolated_name;
             if ($modelAttachments->save()) {
                 $model->attachment_id = $modelAttachments->id;
                 if ($model->save()) {
                     if (count($traveldescription) > 0) {
                         return $this->redirect(['travellerdescription/update', 'id' => $traveldescription->id]);
                     } else {
                         return $this->redirect(['travellerdescription/create', 'traveller_id' => $model->traveller_id]);
                     }
                 }
             }
         }
     } else {
         return $this->render('create', ['model' => $model, 'uploadModel' => $uploadModel, 'traveller_id' => $traveller_id, 'traveldescription' => $traveldescription]);
     }
 }