Upload file using Guzzle 6 to API endpoint

前端 未结 2 1410
借酒劲吻你
借酒劲吻你 2020-12-05 17:58

I am able to upload a file to an API endpoint using Postman.

I am trying to translate that into uploading a file from a form, uploading it using Laravel and posting

2条回答
  •  庸人自扰
    2020-12-05 18:46

    $body = fopen('/path/to/file', 'r');
    $r = $client->request('POST', 'http://httpbin.org/post', ['body' => $body]);
    

    http://docs.guzzlephp.org/en/latest/quickstart.html?highlight=file

提交回复
热议问题