How to get file upload without a form How to get file upload without a form symfony symfony

How to get file upload without a form


The Request has a FileBag, similar to the ParameterBag

So I could get the file specified easily with:

$data = $this->getRequest()->request->all();$file = $this->getRequest()->files->get('file');

and use the document as is from the cookbook:

$document = new Document();$document->setFile($file);$lead->setDocument($document);