我正在尝试从本地主机向我的实时api发送音频文件。当我将音频文件(位于本地主机上)发送到api时, fopen 能够读取该文件,但是当我使用诸如https://example.amazonaws.com/patient_file/audio.mp3
之类的实时URL时,Fopen无法打开它。
$audio_file = 'audio.mp3';
$file_path = 'https://example.amazonaws.com/patient_file' . $audio_file;
$request = $client->post($apiURL, [
'multipart' => [
[
'name' => 'info',
'contents' => 'info',
],
[
'name' => 'file',
'contents' => fopen($file_path, 'r'),
],
$response = $request->getBody();
return $response;
PS 已启用allow_url_fopen