title: Dropbox API v2 PHP upload file issue
body: <p>I am trying to upload a file using Dropbox API v2.
  Unfortunately there is no PHP library for Dropbox API v2.</p>
  
  <p><a href="https://www.dropbox.com/developers/documentation/http/documentation#files-upload" rel="noreferrer">https://www.dropbox.com/developers/documentation/http/documentation#files-upload</a></p>
  
  <p>This is my code:</p>
  
  <pre><code>$token = 'sometoken'; // oauth token
  
  $headers = array("Authorization: Bearer ". $token,
      'Dropbox-API-Arg: {"path": "/test.txt","mode": "add","autorename": true,"mute":false}',
      "Content-Type: application/octet-stream");
  
  
  $url = 'https://content.dropboxapi.com/2/files/upload';
  
  $ch = curl_init($url);
  
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($ch, CURLOPT_POST, true);
  
  $path = './google/file.json';
  $fp = fopen($path, 'rb');
  curl_setopt($ch, CURLOPT_INFILE, $fp);
  curl_setopt($ch, CURLOPT_INFILESIZE, filesize($path));
  
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  
  
  //curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_VERBOSE, 1);
  
  
  $response = curl_exec($ch);
  $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  echo($response.'&lt;br/&gt;');
  echo($http_code.'&lt;br/&gt;');
  
  curl_close($ch);
  echo $response;
  </code></pre>
  
  <p>It creates test.txt but 0 bytes.
  When I check the code it reads 0 byte.</p>
  
  <p>And this is output of code execution:</p>
  
  <pre><code>*   Trying 45.58.74.164...
  * Connected to content.dropboxapi.com (45.58.74.164) port 443 (#0)
  * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
  * successfully set certificate verify locations:
  *   CAfile: C:\xampp\php\extras\ssl\cacert.pem
    CApath: none
  * NPN, negotiated HTTP1.1
  * SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
  * Server certificate:
  *  subject: OU=Domain Control Validated; CN=dl.dropboxusercontent.com
  *  start date: Jul  9 01:10:38 2016 GMT
  *  expire date: May  7 20:27:38 2017 GMT
  *  subjectAltName: host "content.dropboxapi.com" matched cert's "content.dropboxapi.com"
  *  issuer: C=US; ST=Arizona; L=Scottsdale; O=GoDaddy.com, Inc.; OU=http://certs.godaddy.com/repository/; CN=Go Daddy Secure Certificate Authority - G2
  *  SSL certificate verify ok.
  &gt; POST /2/files/upload HTTP/1.1
  Host: content.dropboxapi.com
  Accept: */*
  Authorization: Bearer sometoken
  Dropbox-API-Arg: {"path": "/test.txt","mode": "add","autorename": true,"mute":false}
  Content-Type: application/octet-stream
  Expect: 100-continue
  
  &lt; HTTP/1.1 100 Continue
  &lt; HTTP/1.1 200 OK
  &lt; Server: nginx
  &lt; Date: Thu, 15 Sep 2016 13:37:16 GMT
  &lt; Content-Type: application/json
  &lt; Transfer-Encoding: chunked
  &lt; Connection: keep-alive
  &lt; pragma: no-cache
  &lt; cache-control: no-cache
  &lt; X-Server-Response-Time: 461
  &lt; X-Dropbox-Request-Id: 7b0003052a45a92fac0e7afca80f4f4c
  &lt; X-Robots-Tag: noindex, nofollow, noimageindex
  &lt;
  * Connection #0 to host content.dropboxapi.com left intact
  {"name": "test.txt", "path_lower": "/test.txt", "path_display": "/test.txt", "id": "id:L2W5zzeox5IAAAAAAAAjvg", "client_modified": "2016-09-15T13:37:16Z", "server_modified": "2016-09-15T13:37:16Z", "rev": "ee6e21bf2e5c", "size": 0}&lt;br/&gt;200&lt;br/&gt;{"name": "test.tx
  t", "path_lower": "/test.txt", "path_display": "/test.txt", "id": "id:L2W5zzeox5IAAAAAAAAjvg", "client_modified": "2016-09-15T13:37:16Z", "server_modified": "2016-09-15T13:37:16Z", "rev": "ee6e21bf2e5c", "size": 0}
  </code></pre>