subh's avatar
Level 2

Invalid resource type: array in /home/vagrant/code/vendor/guzzlehttp/psr7/src/Utils.php:334

I am trying to upload form data with a file using Guzzle. One of the form data is an array.


 $response = $client->request('POST', 'someurl.com/api', [  
                'multipart'=> [['name'=> 'name', 'contents' => $request->input('name')],
                    ['name'=> 'tags', 'contents' => $request->input('tags')],		// this is an array
                    ['name'=> 'tagsType', 'contents'  => static::$GENERAL],
                    ['name'=> 'file', 'contents'  => fopen($request->file('file'), 'r')]],    // file
            ]);

0 likes
3 replies
neilstee's avatar
neilstee
Best Answer
Level 34

@subh try to json_encode it

json_encode($request->input('tags'))
2 likes

Please or to participate in this conversation.