title: Codeigniter: Image Upload
body: <p>I have a large form, and I just added an file input to allow users to upload an image.</p>
  
  <p>Here's the new HTML:</p>
  
  <pre><code>&lt;input type="file" name="file_1" /&gt;
  &lt;input type="text" name="image_description_1" class="text-input"/&gt;
  </code></pre>
  
  <p>Here's the new _submit function:</p>
  
  <pre><code>if($this-&gt;CI-&gt;input-&gt;post('file_1')){
      $config['overwrite'] = TRUE;
      $config['allowed_types'] = 'jpg|jpeg|gif|png';
      $config['max_size'] = 2000;
      $config['upload_path'] = realpath(APPPATH . '../assets/uploads/avatars');
  
      $this-&gt;CI-&gt;load-&gt;library('upload', $config);
      $this-&gt;CI-&gt;upload-&gt;do_upload();
  
      $image_data = $this-&gt;CI-&gt;upload-&gt;data();
  
      $image['description'] = $this-&gt;CI-&gt;input-&gt;post('image_description_1');
      $image['user_id'] = $id;
      $image['image'] = $image_data['file_name'];
  
      $this-&gt;CI-&gt;db-&gt;insert('report_images',$image);
  
  }
  </code></pre>
  
  <p>The description and user_id are correctly getting submitted, but the file is lost.</p>
  
  <p>Should I be doing something different?  Not really sure what's going wrong.</p>