【发布时间】:2016-02-13 22:39:12
【问题描述】:
如何在控制器中接收来自 POST 请求的数据? 我不使用树枝。
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)
*/
}
或者我如何序列化(转换)发布数据到对象或数组
我使用 Postman 发送请求,标题为“Content-Type: application/json”。
你能告诉我如何保存文件(图像)吗?
【问题讨论】:
标签: php json symfony post save