0
我有以下代碼將文件上傳到Dropbox的上傳文件到Dropbox的用PHP
$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
"
錯誤消息似乎很清楚 - 您需要檢查您設置的Content-Type標頭。 – andrewsi 2013-04-26 20:31:09
@andrewsi感謝您的答案,但標題不包含錯誤消息中的類型! – 2013-04-26 20:44:04
您是否嘗試過[Dropbox_API](http://code.google.com/p/dropbox-php/wiki/Dropbox_API)for php? – 2013-04-26 20:45:01