我正在尝试使用Guzzle发出发布请求,发送一些参数和文件,但是当我运行应用程序时出现超时错误
我尝试从参数中删除文件,并且请求已正常发送
错误:
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN)
Maximum execution time of 60 seconds exceeded
发出请求的代码
$client = new GuzzleHttp\Client();
$res = $client->sendAsync('post', 'http://api.ocr.space/Parse/Image',[
'headers' => [
'apikey' => 'helloworld',
],
'multipart' => [
[
'name' => 'language',
'contents' => 'por',
],
[
'name' => 'filetype',
'contents' => 'png',
],
[
'name' => 'file',
'contents' => fopen(asset('/public/Screenshot_2.png'), 'r'),
'filename' => 'file.png'
]
]
]);
$content = json_decode($res->getBody(), true);
dd($content);
请在您的php.ini文件中更新您的“最大执行时间”,PHP服务器也会导致发布请求的问题,请尝试切换到apache或xamp服务器。有关更多信息:https : //laracasts.com/discuss/channels/code-review/file-upload-using-guzzle-client
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句