How to get file upload without a form

后端 未结 1 638
暖寄归人
暖寄归人 2021-01-03 17:53

my controller receives post data. It\'s not from a Symfony generated form, but from an AngularJS custom form using FormData.

The normal parameters are r

相关标签:
1条回答
  • 2021-01-03 18:18

    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);
    
    0 讨论(0)
提交回复
热议问题