douang1243 2017-10-25 09:35
浏览 41
已采纳

无法读取HTTP Foundation Symfony 3.3中的“文件”

Recently I updated a symfony project from 3.2 to 3.3. I have an issue with a simple POST with a file. The file is not in the filebag of the http foundation object Request.

public function sendAction(Request $request){
    dump($request->files);
    dump($request->request);
    dump($request->headers);
    if (!$request->files->has("image")) {
        throw new HttpException(Response::HTTP_BAD_REQUEST, 'no "image" field');
    }
}

When I have a look at what it dumped, depending on the content-type of the request, I have different results :

If I use application/x-www-form-urlencoded as header, I have these dump : https://pastebin.com/5HSCAgut (sorry for pastebin links, output is too long)

If i use multipart/form-data as header, I have these dumps : https://pastebin.com/tZdVKNgG

What's wrong with my script ? Am i missing a new feature or security check ?

  • 写回答

1条回答 默认 最新

  • dongxiee0744 2017-10-25 09:43
    关注

    Ok it was a stupid client error. I specified the header :

    Content-type: multipart/form-data
    

    but it should be

    Content-type: multipart/form-data; boundary=-------------BOUNDARYUSEDINREQUEST--------------
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog