我正在尝试使用他们的API将文件上传到OneDrive上的用户文件夹 .
$cfile = curl_file_create(realpath($_POST['ppt-file']));
//place file in folder
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://apis.live.net/v5.0/". $sekoia_folder ."/files?access_token=" . $access_token);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $cfile);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$upload_result = trim(curl_exec($ch));
curl_close($ch);
我收到了API的回复 .
请求实体主体在“Content-Disposition”标头中的值不正确 . 此值的预期格式为“Content-Disposition:form-data; NAME = “文件”;文件名= “[文件名]””“ .
不知道我哪里出错了,但这是预期的http标头 .
POST https://apis.live.net/v5.0/me/skydrive/files?access_token=ACCESS_TOKEN
Content-Type: multipart/form-data; boundary=A300x
--A300x
Content-Disposition: form-data; name="file"; filename="HelloWorld.txt"
Content-Type: application/octet-stream
Hello, World!
--A300x--
提前致谢!
更新:当我将API网址直接放在我的表单的action属性中并将我的文件输入字段重命名为'file'时,文件会上传 . 但后来我只是得到了我的页面上的回复:)不希望我想要发生的事情 .
" method="post" enctype='multipart/form-data'>