我该如何在控制器中接收来自POST请求的数据?我不使用Twig。
public function newAction(Request $request)
{
//when I use
$content = $request->getContent();
// as result I see "string" with need field and value. It's not json
// array
// value like
/*
string '------WebKitFormBoundaryI12ukQBs3HdmPjvh
Content-Disposition: form-data; name="title"
"valuefortitle"
------WebKitFormBoundaryI12ukQBs3HdmPjvh
Content-Disposition: form-data; name="name"
"supername"
------WebKitFormBoundaryI12ukQBs3HdmPjvh--
' (length=253)
*/
}
我应该如何将Post数据序列化(转换)为对象或数组?
我使用Postman发送请求,头部信息为"Content-Type: application/json"。
您可以展示一下如何保存文件(图片)吗?