Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

guzzlehttp submit form file

use GuzzleHttpPsr7;

$response = $client->request('POST', 'http://httpbin.org/post', [
    'multipart' => [
        [
            'name'     => 'field_name',
            'contents' => 'abc'
        ],
        [
            'name'     => 'file_name',
            'contents' => Psr7Utils::tryFopen('/path/to/file', 'r')
        ],
        [
            'name'     => 'other_file',
            'contents' => 'hello',
            'filename' => 'filename.txt',
            'headers'  => [
                'X-Foo' => 'this is an extra header to include'
            ]
        ]
    ]
]);
Source by docs.guzzlephp.org #
 
PREVIOUS NEXT
Tagged: #guzzlehttp #submit #form #file
ADD COMMENT
Topic
Name
1+6 =