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
Post a Comment