title: Dropbox - uploading files from url doesn't work consistently
body: <p>I have a PHP script that uploads files into Dropbox. When I run it from command-line as a standalone script, it works perfectly.</p>
  
  <p>However, when I incorporate my code into the larger project, the file fails to upload, cURL returns "errno" 0 (meaning, no cURL errors), and there's no output from Dropbox's API.</p>
  
  <p>Here is the code that works:</p>
  
  <pre><code>    $token = '&lt;token&gt;';
  $url = "https://content.dropboxapi.com/2/files/upload";
  
      $post_body = file_get_contents("/other/server/url/test.txt");
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url); 
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token,
                                             'Content-Type: application/octet-stream', 
                                             'Dropbox-API-Arg: {"path": "/Dropbox/path/subfolder/test.txt","mode": "add", "autorename": true, "mute": false}'));
  curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body); 
  
  
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
  $data = json_decode(curl_exec($ch), true);
  curl_close($ch); 
  
  print_r($data);
  </code></pre>
  
  <p>.... and here is the broken code:</p>
  
  <pre><code>private function dropbox_uploadFile( $path, $file_source, $file_name = "test1.txt") {
  
  
      echo "&lt;br /&gt;&lt;br /&gt;PATH: ". $path . '/' . $file_name . "&lt;br /&gt;&lt;br /&gt;";
      echo "&lt;br /&gt;&lt;br /&gt;SOURCE: ". $file_source . "&lt;br /&gt;&lt;br /&gt;";
  
  
      $token = '&lt;token&gt;';
      $url = "https://content.dropboxapi.com/2/files/upload";
  
      $post_body = file_get_contents( $file_source );
  
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url); 
      curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token,
                                                 'Content-Type: application/octet-stream', 
                                                 'Dropbox-API-Arg: {"path": ' . $path.'/'.$file_name. '","mode": "add", "autorename": true, "mute": false}'));
  
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body); 
      curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);  // to prevent cURL error #60
  
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
      $data = json_decode(curl_exec($ch), true);
  
      if( ! $data ) {
          echo "&lt;pre&gt;";
          print_r(curl_getinfo($ch));
          echo "&lt;/pre&gt;";
  
          echo "ERROR: " . curl_errno( $ch ) . "&lt;br /&gt;&lt;br /&gt;";
      }
  
      curl_close($ch); 
      print_r($data);
  
  
  }
  </code></pre>