We Want to Hear From You! What Do You Want to See on the Community? Tell us here!

Forum Discussion

amirishaque's avatar
amirishaque
Explorer | Level 4
7 years ago

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-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    7 years ago
    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's avatar
    amirishaque
    Explorer | Level 4
    7 years ago

    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

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,033 PostsLatest Activity: 3 years ago
409 Following

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!