We Want to Hear From You! What Do You Want to See on the Community? Tell us here!
Forum Discussion
amirishaque
7 years agoExplorer | Level 4
video size is 0 bytes on upload
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);
3 Replies
- Greg-DB7 years ago
Dropbox Community Moderator
To begin debugging this, I recommend:
- Confirm that your $files1 value is correct.
- Confirm that the file at that path is non-zero and that you have access to it.
- Confirm that the 'fread' call is returning the non-zero data. - amirishaque7 years agoExplorer | Level 4
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
- Greg-DB7 years ago
Dropbox Community Moderator
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.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,033 PostsLatest Activity: 3 years ago
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or 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!