guzzlehttp submit form file

Solutions on MaxInterview for guzzlehttp submit form file by the best coders in the world

showing results for - "guzzlehttp submit form file"
Nelson
23 Jun 2017
1use GuzzleHttp\Psr7;
2
3$response = $client->request('POST', 'http://httpbin.org/post', [
4    'multipart' => [
5        [
6            'name'     => 'field_name',
7            'contents' => 'abc'
8        ],
9        [
10            'name'     => 'file_name',
11            'contents' => Psr7\Utils::tryFopen('/path/to/file', 'r')
12        ],
13        [
14            'name'     => 'other_file',
15            'contents' => 'hello',
16            'filename' => 'filename.txt',
17            'headers'  => [
18                'X-Foo' => 'this is an extra header to include'
19            ]
20        ]
21    ]
22]);