php - Guzzle ~6.0 multipart and form_params -


i trying upload file , send post parameters @ same time this:

$response = $client->post('http://example.com/api', [     'form_params' => [         'name' => 'example name',     ],     'multipart' => [         [             'name'     => 'image',             'contents' => fopen('/path/to/image', 'r')         ]     ] ]); 

however form_params fields ignored , multipart fields present in post body. can send both @ guzzle 6.0 ?

i ran same problem. need add form_params multipart array. 'name' form element name , 'contents' value. example code supplied become:

$response = $client->post('http://example.com/api', [     'multipart' => [         [             'name'     => 'image',             'contents' => fopen('/path/to/image', 'r')         ],         [             'name'     => 'name',             'contents' => 'example name'         ]     ] ]); 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -