title: Codeigniter: Image upload through web services
body: <p>I am trying to upload one image through web services . following is the code </p>
  
  <pre><code>  public function upload() {
          $config['upload_path']          = './uploads/';
          $config['allowed_types'] = 'gif|jpg|png|mp4|jpeg';
          $config['max_size']             = 100;
          $config['max_width']            = 1024;
          $config['max_height']           = 768;
          $this-&gt;load-&gt;library('upload', $config);
          $this-&gt;upload-&gt;initialize($config); 
          $this-&gt;data['data']= $_FILES;  
          echo json_encode($this-&gt;data); die; 
  
          if ( ! $this-&gt;upload-&gt;do_upload('userfile'))
          {
                  $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
                  $this-&gt;data['data']= $error ; 
                  echo json_encode($this-&gt;data['data']); 
                  die; 
          }
          else
          {
                  $data = array('upload_data' =&gt; $this-&gt;upload-&gt;data());
                                          $this-&gt;data['data']= 'done' ; 
  
                  echo json_encode($this-&gt;data['data']); 
                  die;
           }
  }
  </code></pre>
  
  <p>if i <code>json_encode($_FILES)</code> this is the response on mobile </p>
  
  <pre><code> data =     {
          userfile =         {
              error = 0;
              name = pen;
              size = 38238;
              "tmp_name" = "/tmp/phpEsEQNK";
              type = jpeg;
          };
      };
  </code></pre>
  
  <p>when i print the errors array this is what i get </p>
  
  <pre><code>error = "&lt;p&gt;The filetype you are attempting to upload is not allowed.&lt;/p&gt;";
  </code></pre>
  
  <p>Please check both responses printed and let me know how can i fix this . </p>