cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

video size is 0 bytes on upload

video size is 0 bytes on upload

amirishaque
Explorer | Level 4

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 3

Greg-DB
Dropbox Staff
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.

amirishaque
Explorer | 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-DB
Dropbox Staff

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.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    amirishaque Explorer | Level 4
What do Dropbox user levels mean?