我想在文件夹中的一个驱动器中上传文档,并发送curl请求以上传并收到错误的请求错误。
$uri = 'https://apis.live.net/v5.0/folder.6971fd0b7e644a5a.6971FD0B7E644A5A!329/files/phocapdf-demo.pdf?access_token=EwAQA61DBAAUGCC....';
protected function curl_put($uri, $fp) {
$output = "";
$pointer = fopen($fp, 'r+');
$stat = fstat($pointer);
$pointersize = $stat['size'];
$ch = curl_init($uri);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILE, $pointer);
curl_setopt($ch, CURLOPT_INFILESIZE, (int)$pointersize);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
$output = curl_exec($ch);
$this->dd($output); //get error
}
这个功能用于调试
function dd($value)
{
echo "<pre>";
print_r($value);
echo "</pre>";
exit;
}