src/Graviton/FileBundle/Manager/FileManager.php
private function getUploadedFileFromRequest(Request $request)
    {
        $file = false;

        if ($request->files instanceof FileBag && $request->files->count() > 0) {
            if ($request->files->count() > 1) {
                throw new InvalidArgumentException('Only 1 file upload per requests allowed.');
            }
            $files = $request->files->all();
            $file = reset($files);
            if ($this->allowedMimeTypes && !in_array($file->getMimeType(), $this->allowedMimeTypes)) {
                throw new InvalidArgumentException('File mime type: '.$file->getMimeType().' is not allowed.');
            }
        }

        return $file;
    }
private function getUploadedFileFromRequest(Request $request)
    {
        $file = false;

        if ($request->files instanceof FileBag && $request->files->count() > 0) {
            if ($request->files->count() > 1) {
                throw new InvalidArgumentException('Only 1 file upload per requests allowed.');
            }
            $files = $request->files->all();
            $file = reset($files);
            if ($this->allowedMimeTypes && !in_array($file->getMimeType(), $this->allowedMimeTypes)) {
                throw new InvalidArgumentException('File mime type: '.$file->getMimeType().' is not allowed.');
            }
        }

        return $file;
    }
private function getUploadedFileFromRequest ( Request $ request ) { $ file = false ; if ( $ request -> files instanceof FileBag && $ request -> files -> count ( ) > 0 ) { if ( $ request -> files -> count ( ) > 1 ) { throw new InvalidArgumentException ( 'Only 1 file upload per requests allowed.' ) ; } $ files = $ request -> files -> all ( ) ; $ file = reset ( $ files ) ; if ( $ this -> allowedMimeTypes && ! in_array ( $ file -> getMimeType ( ) , $ this -> allowedMimeTypes ) ) { throw new InvalidArgumentException ( 'File mime type: ' . $ file -> getMimeType ( ) . ' is not allowed.' ) ; } } return $ file ; }
Set global uploaded file.
Only ONE file allowed per upload.

@param Request $request service request
@return UploadedFile if file was uploaded
@throws InvalidArgumentException
Set global uploaded file . Only ONE file allowed per upload .