title: Uploading image using Codeigniter (API)
body: <p>I'm trying to implement a simple image upload function in my API using codeigniter. So far this is my code : </p>
  
  <pre><code>function addpicture_post()
  {
        $config['upload_path'] = './upload/';
  $config['allowed_types'] = 'gif|jpg|png';
  $config['max_size'] = '10000';
  $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());
      $info = 'not working';
      $this-&gt;response($info);
      }
  }
  }
  </code></pre>
  
  <p>When I'm using apigee (<a href="https://apigee.com/console/others" rel="nofollow">https://apigee.com/console/others</a>) to try it, if I do not set any parameter, I have the following message : </p>
  
  <p>HTTP/1.1 200 OK
  Status:
  200
  Date:
  Thu, 12 Dec 2013 15:30:16 GMT
  Content-Length:
  367
  Keep-Alive:
  timeout=15, max=100
  Content-Type:
  application/json
  X-Powered-By:
  PHP/5.3.5-1ubuntu7.11
  Server:
  Apache/2.2.17 (Ubuntu)</p>
  
  <p>You did not select a file to upload.</p>
  
  <p>So far so good. But when I'm trying to upload an image file (with the file attachement parameter in apogee, which I named "userfile"), I have the following response : </p>
  
  <p><strong>Invalid test url</strong></p>
  
  <p>I'm fairly struggling with that for a few hours now, I've tried to look at code igniter's documentation but unfortunately it has nothing to do with APIs , and I can't figure out how to upload files without using a form. </p>
  
  <p>I'm not quite sure if the problem is coming from the service I'm using to test it, apigee, or if the problem is coming from the code. At the end, my goal is to implement this function in an iphone app I'm coding, but I'd like to be able to test the function before trying to include it in my app. </p>
  
  <p>Anyone could give me informations about file upload within an API ? And how to test it properly ? Thank you.</p>