Dropbox PHP v2上传问题 [英] Dropbox PHP v2 upload issue
问题描述
我做了一个 这也是从请求返回cURL 谢谢, 更新(CODE): 这是一个PUT请求,但必要时发送POST。 得出结论: I did a Also this is the return from the request cURL Thanks, UPDATE (CODE):
This version of the code seems to trick curl into acting like it's a PUT request, but has it send "POST" as necessary. That yields:
这篇关于Dropbox PHP v2上传问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! php
cURL
代码,结果是成功但是返回大小为0的问题,可以任何人帮助我,我使用这个页面上的代码 Dropbox的V2 API - 大文件上传
我不知道为什么文件大小为零。任何人都可以帮助我吗?
{name:2.jpg,path_lower:/images/2.jpg,id:id:92FZUH08Y6AAAAAVVAAAEA,client_modified:2015-12-10T11:02 :38Z,server_modified:2015-12-10T11:02:38Z,rev:1c40f677f1,size:0}
$文件名= '2.JPG';
$ cheaders = array('Authorization:Bearer = TOKEN =','Content-Type:application / octet-stream','Dropbox-API-Arg:{path:/ images /'.$ filename 。,mode:add}');
$ ch = curl_init('https://content.dropboxapi.com/2/files/upload');
curl_setopt($ ch,CURLOPT_HTTPHEADER,$ cheaders);
curl_setopt($ ch,CURLOPT_POST,true);
$ fpath ='/home2/public_html/uploads/'.$filename;
$ fp = fopen($ fpath,'rb');
curl_setopt($ ch,CURLOPT_INFILE,$ fp);
curl_setopt($ ch,CURLOPT_INFILESIZE,filesize($ fpath));
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,true);
$ response = curl_exec($ ch);
curl_close($ ch);
fclose($ fp);
<?php
$ path ='test_php_upload.txt';
$ fp = fopen($ path,'rb');
$ size = filesize($ path);
$ b $ cheaders = array('Authorization:Bearer = TOKEN =',
'Content-Type:application / octet-stream',
'Dropbox-API-Arg:{ path:/ test /'.$ path。',mode:add}');
$ ch = curl_init('https://content.dropboxapi.com/2/files/upload');
curl_setopt($ ch,CURLOPT_HTTPHEADER,$ cheaders);
curl_setopt($ ch,CURLOPT_PUT,true);
curl_setopt($ ch,CURLOPT_CUSTOMREQUEST,'POST');
curl_setopt($ ch,CURLOPT_INFILE,$ fp);
curl_setopt($ ch,CURLOPT_INFILESIZE,$ size);
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,true);
$ response = curl_exec($ ch);
echo $ response;
curl_close($ ch);
fclose($ fp);
?>
{name:test_php_upload.txt,path_lower:/test/test_php_upload.txt,id:id:25N5ksooX-sAAAAAAAHcWg,client_modified:2015-12 -10T22:35:07Z,server_modified:2015-12-10T22:35:07Z,rev:56384021eccc7,size:15}
php
cURL
code, the result is success but the problem it return the size 0, can anyone help me out, I do use the code on this page Dropbox v2 API - large file uploads
I'm not sure why the file size is zero. can anyone help me out?{"name": "2.jpg", "path_lower": "/images/2.jpg", "id": "id:92FZUH08Y6AAAAAVVAAAEA", "client_modified": "2015-12-10T11:02:38Z", "server_modified": "2015-12-10T11:02:38Z", "rev": "1c40f677f1", "size": 0}
$filename='2.jpg';
$cheaders = array('Authorization: Bearer =TOKEN=','Content-Type: application/octet-stream','Dropbox-API-Arg: {"path":"/images/'.$filename.'", "mode":"add"}');
$ch = curl_init('https://content.dropboxapi.com/2/files/upload');
curl_setopt($ch, CURLOPT_HTTPHEADER, $cheaders );
curl_setopt($ch, CURLOPT_POST, true);
$fpath = '/home2/public_html/uploads/'.$filename;
$fp = fopen($fpath, 'rb');
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($fpath));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
fclose($fp);
<?php
$path = 'test_php_upload.txt';
$fp = fopen($path, 'rb');
$size = filesize($path);
$cheaders = array('Authorization: Bearer =TOKEN=',
'Content-Type: application/octet-stream',
'Dropbox-API-Arg: {"path":"/test/'.$path.'", "mode":"add"}');
$ch = curl_init('https://content.dropboxapi.com/2/files/upload');
curl_setopt($ch, CURLOPT_HTTPHEADER, $cheaders);
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, $size);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
echo $response;
curl_close($ch);
fclose($fp);
?>
{"name": "test_php_upload.txt", "path_lower": "/test/test_php_upload.txt", "id": "id:25N5ksooX-sAAAAAAAHcWg", "client_modified": "2015-12-10T22:35:07Z", "server_modified": "2015-12-10T22:35:07Z", "rev": "56384021eccc7", "size": 15}