title: how to upload file from codeigniter app to dropbox
body: <p>I have a controller to upload image to my web server. I want to upload that image to dropbox as well during the process. how would I do it?</p>
  
  <p>This is my simple upload.php controller:</p>
  
  <pre><code>function index() {
      // get the binary data
      $file = file_get_contents("php://input");
  
      // prepare new name for upload image
      $name =rand().time().'jpg';
  
      $path = site_url('photo');
  
      // save to server directory
      file_put_contents($path.$name, $file);
  
      // save the name and id of the post to post photo table
      $input =  array(    'name' =&gt; $name,
                          'post_id'=&gt; $id
                      );
  
      $this-&gt;db-&gt;insert('post_photo', $input);
  
  }
  </code></pre>