public function uploadPhoto()
    {
        $result = [];
        if ($this->validate()) {
            $fileOrgname = Helper::validateFilename($this->file->name, 40);
            $filename = $fileOrgname;
            $filePath = Media::getCurrentDirectory() . DIRECTORY_SEPARATOR . $filename;
            $result['originName'] = $this->file->name;
            if ($this->file->saveAs($filePath)) {
                $result['originPath'] = $filePath;
                if ($this->options->resize) {
                    $tsize = (new Size(getimagesize($filePath)))->resize($this->options->resizeTo);
                    $size    = new \Imagine\Image\Box($tsize->width, $tsize->height);
                    $imagine = new \Imagine\Gd\Imagine();
                    $resizedName = 'primary_' . $filename;
                    $resizedPath = Media::getCurrentDirectory() . DIRECTORY_SEPARATOR . $resizedName;
                    $imagine->open($filePath)->resize($size)->save($resizedPath);
                    $filename = $resizedName;
                    $filePath = $resizedPath;
                }
                $result['success'] =  true;
                $result['fileName'] = $filename;
                $result['filePath'] = $filePath;
                $result['size'] = filesize($filePath);
                if ($this->options->generateThumbnail) {
                    $thumbName = 'thumb_' . $fileOrgname;
                    $thumbPath = Media::getCurrentDirectory() . DIRECTORY_SEPARATOR . $thumbName;
                    $tsize = (new Size(getimagesize($filePath)))->resize($this->options->thumbnailSize);
                    $size    = new \Imagine\Image\Box($tsize->width, $tsize->height);
                    $imagine = new \Imagine\Gd\Imagine();
                    try {
                        $imagine->open($filePath)->thumbnail($size)->save($thumbPath);
                        $result['thumbnailPath'] = $thumbPath;
                        $result['thumbnailName'] = $thumbName;

                    } catch (\Exception $e) {
                        //Nothing to do
                        \Yii::$app->log->logger->log($e);
                    }
                }
            }

        }
        $result['error'] = new ModelErrors($this->getErrors());
        return new UploadResult($result);
    }