1 回答

TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超2個(gè)贊
根據(jù)Guzzle 文檔
筆記
multipart 不能與 form_params 選項(xiàng)一起使用。您將需要使用其中之一。對(duì) application/x-www-form-urlencoded 請(qǐng)求使用 form_params,對(duì) multipart/form-data 請(qǐng)求使用 multipart。
此選項(xiàng)不能與 body、form_params 或 json 一起使用
因此,您不能將 form_params 與 multipart/form-data 一起使用,并且必須以這種方式使用 multipart 方法:
$client = new \GuzzleHttp\Client();
$url? ?= "https://api.vidado.ai/read/text";
$requestAPI = $client->request('POST', $url, [
? ? 'headers' => [
? ? ? ? 'Accept' => 'application/json',
? ? ? ? 'Authorization' => 'my apikey',
? ? ? ? 'Content-Type' => 'multipart/form-data'
? ? ],
? ? 'multipart' => [
? ? ? ? [
? ? ? ? ? ? 'name'? ? ?=> 'image',
? ? ? ? ? ? 'contents' => fopen('/path/to/file', 'r'),
? ? ? ? ? ? 'filename' => 'custom_filename.jpg'
? ? ? ? ],
? ? ? ? [
? ? ? ? ? ? 'name' => 'autoscale',
? ? ? ? ? ? 'contents'=> true
? ? ? ? ]
? ? ]
]);
- 1 回答
- 0 關(guān)注
- 217 瀏覽
添加回答
舉報(bào)