With AngularJS I post form datas and file in one request. I can't handle datas properly in the controller of symfony2.
I only get a full string of datas with $request->getContent()
but it is not parsed.
here is more details :
1 - I send data like this example and it works => http://shazwazza.com/post/Uploading-files-and-JSON-data-in-the-same-request-with-Angular-JS
2 - here are datas sent :
-----------------------------23743060120122
Content-Disposition: form-data; name="model"
{"type_inventaire_id":"8","profondeur_id":"2","code_pays_elv":"FR"}
-----------------------------23743060120122
Content-Disposition: form-data; name="file"; filename="importChep.txt"
Content-Type: text/plain
69182002
22096034
22096033
00110011
//69182007
69182003
-----------------------------23743060120122
3 - i can only get datas with $request->getContent()
but it is not parsed
I would like to get it like that :
$file = $request->files->get('file');
$model = $request->get('model');
I look for a solution for one day but i did not found anything...
Anyone have an idea?
Are you doing a POST or a PUT request? I found out that when using PUT method symfony doesn't give you access to the attributes, however using POST you should be able to access your data:
$file = $request->files->get('file');
$model = $request->request->get('model');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With