我有以下代码将文件上传到 Dropbox
$context = $this->createRequestContext($url, "PUT");
curl_setopt($context, CURLOPT_BINARYTRANSFER, true);
$fh = fopen($src_file, 'rb');
curl_setopt($context,CURLOPT_HEADER,true);
curl_setopt($context, CURLOPT_INFILE, $fh); // file pointer
curl_setopt($context, CURLOPT_INFILESIZE, filesize($src_file));
$context = $this->createRequestContext($url, "PUT", $content);
$meta = json_decode(self::execCurlAndClose($context));
fclose($fh);
return $meta;
我的问题是每次我收到以下错误作为响应:
["error"]=> string(121) "Upload failed. Content-Type must not be empty and not one of ('application/x-www-form-urlencoded', 'multipart/form-data')"
我现在正在尝试上传任何类型的文件,但将来我只想上传 pdf 文件。你能帮我指出我做错了什么吗?
这是标题:
["method"]=>
string(3) "PUT"
["header"]=>
string(64) "Content-Length: 230783
Content-Type: application/octet-stream
"