maheshbhanushali's avatar

upload image file

Hi, can anyone help me with following issue. I am using remote api and I have a form with image file upload, Now the form data are submitted to my server and from there I am hitting remote api with guzzle http client. I am able to send data to remote api using guzzle http client but not the image file.

0 likes
6 replies
maheshbhanushali's avatar

@gregurco Argument 2 passed to GuzzleHttp\Psr7\MultipartStream::addElement() must be of the type array, string given, $this->client->put('addProducts', ['debug' => true,'verify' => false, 'http_errors' => true, 'multipart' => ['name' => $key, 'contents' => fopen(public_path().'/images/no_image.gif', 'r'), 'headers' => ['accesstoken' => session('instadeliApiToken')]]]);

gregurco's avatar

Try this:

$this->client->put('addProducts', ['debug' => true,'verify' => false, 'http_errors' => true, 'multipart' => [['name' => $key, 'contents' => fopen(public_path().'/images/no_image.gif', 'r'), 'headers' => ['accesstoken' => session('instadeliApiToken')]]}]);
1 like
maheshbhanushali's avatar

@gregurco that extra square bracket, and ya that header should be out of multipart array and it work like charm :) thanks

Please or to participate in this conversation.