$absolutepath=dirname(__FILE__)."/"."upload/aa.jpg"
$data = [
'binFile'=>new \CURLFile($absolutepath),
'filename' => "文件名字"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->url);
curl_setopt($ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,60);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'token:'sd4a7sd45a4dqwe'
));
$result = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
print_r($result);
|