[英]$request->files->all() is always empty
I'm testing my API with POSTMAN and when I try to send any file the content of $request->files->all() is always empty. 我正在使用POSTMAN测试我的API,当我尝试发送任何文件时,$ request-> files-> all()的内容始终为空。
$request->server->parameters["CONTENT_LENGTH"] seems to change depending on the file size. $ request-> server-> parameters [“CONTENT_LENGTH”]似乎会根据文件大小而改变。 But I don't find a way to reach the file content. 但我找不到一种方法来获取文件内容。
Tried also with $_FILES, but the same result. 尝试使用$ _FILES,但结果相同。
I even did a var_dump($_FILES); 我甚至做了一个var_dump($ _ FILES); in my app_dev.php directly before reaching anything else from Symfony's framework. 在我的app_dev.php之前直接从Symfony的框架中获取任何其他内容。
My php.ini seems to be alright: file_uploads: on upload_max_filesize: more than enough post_max_size: more than enough 我的php.ini似乎没问题:file_uploads:on upload_max_filesize:绰绰有余post_max_size:绰绰有余
In POSTMAN I tried both ways of sending a file: binary and form-data file. 在POSTMAN中,我尝试了两种方式发送文件:binary和form-data文件。
A POSTMAN code example looks like this using form-data: POSTMAN代码示例使用form-data看起来像这样:
PUT /retain_inspecciones/web/app_dev.php/api/planningfiles/6?files=true HTTP/1.1
Host: symfony.dev
symfonytoken: Bearer my-token
Cache-Control: no-cache
Postman-Token: 9c9cd91a-99f2-57ab-a290-966074b219f3
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="fileName"; filename=""
Content-Type:
------WebKitFormBoundary7MA4YWxkTrZu0gW--
I'm not sure of why the part where the file should be is the empty string and Content-Type is empty. 我不确定为什么文件所在的部分是空字符串而Content-Type是空的。 But it seems to be the way POSTMAN does so. 但它似乎是POSTMAN这样做的方式。
Any idea? 任何想法?
Finally I decided to try curl instead of Postman and it worked on first try. 最后我决定尝试curl而不是Postman,它首先尝试了。
I don't know how curl differs from POSTMAN when building the request but I'm happy with it. 在构建请求时我不知道curl与POSTMAN有什么不同,但我很满意。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.