multipart
摘要
设置请求的主体为 multipart/form-data 表单。
类型
array
常量
GuzzleHttp\RequestOptions::MULTIPART
multipart 的值是一个关联数组,每个元素包含以下键值对:
name: (string, required) 表单字段名称contents: (StreamInterface/resource/string, required) 表单元素中要使用的数据headers: (array) 可选的表单元素要使用的键值对数组filename: (string) 可选的作为要发送的文件名称
1. $client->request('POST', '/post', [
2. 'multipart' => [
3. [
4. 'name' => 'foo',
5. 'contents' => 'data',
6. 'headers' => ['X-Baz' => 'bar']
7. ],
8. [
9. 'name' => 'baz',
10. 'contents' => fopen('/path/to/file', 'r')
11. ],
12. [
13. 'name' => 'qux',
14. 'contents' => fopen('/path/to/file', 'r'),
15. 'filename' => 'custom_filename.txt'
16. ],
17. ]
18. ]);
