I have a form where video can be uploaded and sent to remote destination. I have a cURL request which I want to 'translate' to PHP using Guzzle.
So far I have this:
public function upload(Request $request) { $file = $request->file('file'); $fileName = $file->getClientOriginalName(); $realPath = $file->getRealPath(); $client = new Client(); $response = $client->request('POST', 'http://mydomain.de:8080/spots', [ 'multipart' => [ [ 'name' => 'spotid', 'country' => 'DE', 'contents' => file_get_contents($realPath), ], [ 'type' => 'video/mp4', ], ], ]); dd($response); } This is cURL which I use and want to translate to PHP:
curl -X POST -F 'body={"name":"Test","country":"Deutschland"};type=application/json' -F 'file=@C:\Users\PROD\Downloads\617103.mp4;type= video/mp4 ' http://mydomain.de:8080/spots So when I upload the video, I want to replace this hardcoded
C:\Users\PROD\Downloads\617103.mp4.
When I run this, I get an error:
Client error:
POST http://mydomain.de:8080/spotsresulted in a400 Bad Requestresponse: request body invalid: expecting form value 'body`'Client error:
POST http://mydomain.de/spotsresulted in a400 Bad Requestresponse: request body invalid: expecting form value 'body'