[英]Postman and Silverstripe API endpoint multipart form with file upload
I have created a very simple method to accept incoming multipart form-data that includes a file. 我创建了一个非常简单的方法来接受包含文件的多部分表单数据。 I'm using Postman to do my testing.
我正在使用Postman进行测试。 I can't seem to get the
$_FILES
data it just returns an empty array. 我似乎无法获得
$_FILES
数据,它只是返回一个空数组。 I can get all the other data. 我可以获取所有其他数据。
My method looks like: 我的方法如下:
public function UploadFile($request){
Debug::dump($request);
Debug::dump($_FILES);
}
In Postman I have: 在邮递员中,我有:
url: http://localhost/sensibel-cms/home/UploadFile 网址: http:// localhost / sensibel-cms / home / UploadFile
headers: none 标头:无
body: form-data 正文:表单数据
key1: UID key1:UID
value1: 1234567 值1:1234567
file: testupload.png 文件:testupload.png
I've attached a image that might make more sense: 我附上了一张可能更有意义的图像:
From the screenshot it seems you are doing the right thing, in particular, headers Content-Type
and Content-Length
look good. 从屏幕截图中,您似乎做对了,特别是标头
Content-Type
和Content-Length
看起来不错。 However, the header Origin: chrome-extension ...
indicates you are using Postman Chrome app which is deprecated , so try replicating the issue using Postman native app. 但是,标题
Origin: chrome-extension ...
表示您正在使用已弃用的 Postman Chrome应用程序,因此请尝试使用Postman本机应用程序复制问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.