how to upload multiple images using guzzle
$output = [];
foreach ($request->images as $image ) {
$output[] = [
'name' => 'image[]',
'contents' => fopen( $image->getPathname(), 'r' ),
'filename' => $image->getClientOriginalName()
];
}
$output [] =
[
'name' => 'product_name',
'contents' => \request()->get( 'name' )
];
$output [] = [
'name' => 'cateogry',
'contents' => \request()->get( 'category_id' )
];
$output [] = [
'name' => 'subcategory',
'contents' => \request()->get( 'sub_category_id' )
];
$token = session()->get('token');
$client = new Client( [
'base_uri' => "http://000.000.00.00:9000/",
]);
$response = $client->request( 'POST', 'api/vendor/products', [
'headers' => ['Authorization' => 'Bearer'.$token],
'multipart'=> $output
]);
$data = \GuzzleHttp\json_decode($response->getBody());