【发布时间】:2015-10-18 15:40:46
【问题描述】:
使用 AngularJS,我在一个请求中发布表单数据和文件。我无法在 symfony2 的控制器中正确处理数据。
我只得到$request->getContent() 的完整数据字符串,但它没有被解析。
这里有更多细节:
1 - 我像这个例子一样发送数据并且它有效 => http://shazwazza.com/post/Uploading-files-and-JSON-data-in-the-same-request-with-Angular-JS
2 - 这是发送的数据:
-----------------------------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 - 我只能用$request->getContent() 获取数据,但它没有被解析
我想得到它:
$file = $request->files->get('file');
$model = $request->get('model');
我寻找了一天的解决方案,但我没有找到任何东西......
有人有想法吗?
【问题讨论】:
标签: javascript php angularjs symfony multipartform-data