Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
when i upload my app using php api version 2 it upload the file but the size of file is 0 bytes
below is mine code ..... can someone guide me
$headers = array('Authorization: Bearer '. $token,
'Content-Type: application/octet-stream',
'Dropbox-API-Arg: '.
json_encode(
array(
"path"=> '/'. date("l-m-y") .'/'. basename($files1),
"mode" => "add",
"autorename" => true,
"mute" => false
)
)
);
$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
$path = $files1;
$fp = fopen($path, 'rb');
$filesize = filesize($path);
curl_setopt($ch, CURLOPT_POSTFIELDS, fread($fp, $filesize));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($ch, CURLOPT_VERBOSE, 1); // debug
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($http_code==200){
curl_close($ch);
how can i give the temporary path of my file to this ......... so it upload file directly ..... now i first upload file to server than it upload that file to dropbox
If you want to upload files directly from the client, instead of going through your server, you can use the functionality provided by /2/files/get_temporary_upload_link:
https://www.dropbox.com/developers/documentation/http/documentation#files-get_temporary_upload_link
The documentation there includes information on how to do that. Note that it's still in preview though, so it's subject to change without notice.
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!