private function doRequestUpload(UploadedFile $file)
    {
        $tmpDirectory = $this->getApplication()->getTemporaryDir();
        $data = [];

        if (null !== $file) {
            if ($file->isValid()) {
                if ($file->getClientSize() <= $file->getMaxFilesize()) {
                    $data = $this->buildData($file->getClientOriginalName(), $file->guessExtension());
                    $file->move($tmpDirectory, $data['filename']);
                    $data['size'] = round($file->getClientSize() / 1024, 2);
                    if ($imageInfo = @getimagesize( $data['path'])) {
                        if (isset($imageInfo[0]) && isset($imageInfo[1])) {
                            $data['width'] = $imageInfo[0];
                            $data['height'] = $imageInfo[1];
                        }
                    } else {
                        $data['width'] = 0;
                        $data['height'] = 0;
                    }
                } else {
                    throw new BadRequestHttpException('Too big file, the max file size is ' . $file->getMaxFilesize());
                }
            } else {
                throw new BadRequestHttpException($file->getErrorMessage());
            }
        }

        return $data;
    }
private function doRequestUpload(UploadedFile $file)
    {
        $tmpDirectory = $this->getApplication()->getTemporaryDir();
        $data = [];

        if (null !== $file) {
            if ($file->isValid()) {
                if ($file->getClientSize() <= $file->getMaxFilesize()) {
                    $data = $this->buildData($file->getClientOriginalName(), $file->guessExtension());
                    $file->move($tmpDirectory, $data['filename']);
                    $data['size'] = round($file->getClientSize() / 1024, 2);
                    if ($imageInfo = @getimagesize( $data['path'])) {
                        if (isset($imageInfo[0]) && isset($imageInfo[1])) {
                            $data['width'] = $imageInfo[0];
                            $data['height'] = $imageInfo[1];
                        }
                    } else {
                        $data['width'] = 0;
                        $data['height'] = 0;
                    }
                } else {
                    throw new BadRequestHttpException('Too big file, the max file size is ' . $file->getMaxFilesize());
                }
            } else {
                throw new BadRequestHttpException($file->getErrorMessage());
            }
        }

        return $data;
    }
private function doRequestUpload ( UploadedFile $ file ) { $ tmpDirectory = $ this -> getApplication ( ) -> getTemporaryDir ( ) ; $ data = [ ] ; if ( null !== $ file ) { if ( $ file -> isValid ( ) ) { if ( $ file -> getClientSize ( ) <= $ file -> getMaxFilesize ( ) ) { $ data = $ this -> buildData ( $ file -> getClientOriginalName ( ) , $ file -> guessExtension ( ) ) ; $ file -> move ( $ tmpDirectory , $ data [ 'filename' ] ) ; $ data [ 'size' ] = round ( $ file -> getClientSize ( ) / 1024 , 2 ) ; if ( $ imageInfo = @ getimagesize ( $ data [ 'path' ] ) ) { if ( isset ( $ imageInfo [ 0 ] ) && isset ( $ imageInfo [ 1 ] ) ) { $ data [ 'width' ] = $ imageInfo [ 0 ] ; $ data [ 'height' ] = $ imageInfo [ 1 ] ; } } else { $ data [ 'width' ] = 0 ; $ data [ 'height' ] = 0 ; } } else { throw new BadRequestHttpException ( 'Too big file, the max file size is ' . $ file -> getMaxFilesize ( ) ) ; } } else { throw new BadRequestHttpException ( $ file -> getErrorMessage ( ) ) ; } } return $ data ; }
Upload file from the request

@param  UploadedFile $file
@return Array $data Retrieve into the content of response
@throws BadRequestHttpException The file is too big
Upload file from the request