title: How to upload image via CURL to Codeigniter REST API
body: <p>I'm using a REST API in Codeigniter and trying to set up an image upload method. I've managed to upload fine using a multipart form but get a file type error using the REST client below. I think the problem is "file_type" is showing as "application/octet-stream".</p>
  
  <p>(Codeigniter Upload: <a href="http://codeigniter.com/user_guide/libraries/file_uploading.html" rel="nofollow">http://codeigniter.com/user_guide/libraries/file_uploading.html</a>)</p>
  
  <p>REST Method</p>
  
  <pre><code>function do_upload_post()
  {
      $config['upload_path'] = './savefiles/';
      $config['allowed_types'] = 'gif|jpg|png';
      $config['max_size'] = '100';
      $config['max_width']  = '1024';
      $config['max_height']  = '768';
      $this-&gt;load-&gt;library('upload', $config);
  
      if ( ! $this-&gt;upload-&gt;do_upload() )
      {
          print_r($this-&gt;upload-&gt;display_errors('', ''));
          print_r($this-&gt;upload-&gt;data());
      }
  }
  </code></pre>
  
  <p>REST Client</p>
  
  <pre><code>function curl_upload(){
      $url = 'http://localhost/api/file/do_upload';
      $file = 'C:\inetpub\wwwroot\ds_site\designs\pics\file.jpg';
      $ch = curl_init($url);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_POST, true);
      $post = array(
          "userfile" =&gt; "@$file"
      );
      curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
      $response = curl_exec($ch);
      echo $response;
  
      curl_close($ch);
  }
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>The filetype you are attempting to upload is not allowed.
  Array
  (
      [file_name] =&gt; aliens.jpg
      [file_type] =&gt; application/octet-stream
      [file_path] =&gt; C:/inetpub/wwwroot/ds_site/savefiles/
      [full_path] =&gt; C:/inetpub/wwwroot/ds_site/savefiles/aliens.jpg
      [raw_name] =&gt; aliens
      [orig_name] =&gt; 
      [client_name] =&gt; aliens.jpg
      [file_ext] =&gt; .jpg
      [file_size] =&gt; 103745
      [is_image] =&gt; 
      [image_width] =&gt; 
      [image_height] =&gt; 
      [image_type] =&gt; 
      [image_size_str] =&gt; 
  )
  </code></pre>