当我尝试使用guzzlehttp 6上传文件时:
class A(object):
my_class_variable = 'hello'
我在尝试创建标题时最终收到错误:
$response = $this->client->post($uri, [
'multipart' => [
[
'name' => 'File-Name',
'filename' => $document->name,
//'Mime-Type' => $document->mime_type,
'contents' => fopen( $file->getPathname(), 'r' ),
'headers' => [
'Access-Token' => $this->token,
]
]
]
] );
我很难过。
答案 0 :(得分:2)
尝试
$response = $this->client->post($uri, [
'multipart' => [
[
'name' => 'File-Name',
'filename' => $document->name,
'contents' => fopen( $file->getPathname(), 'r' ),
],
],
'headers' => [
'Access-Token' => $this->token,
],
]);