title: You did not select a file to upload, file upload error in Codeigniter
body: <p>I'm trying to add singer information with image. the information can be successfully added without image but if i try to insert data with image, error occurred with "You did not select a file to upload" message.
  My controller function is this...</p>
  
  <pre><code>   public function add_edit_singer($id = '')
     {
      if($this-&gt;input-&gt;post('save_singer_info')){
  
          $post=$this-&gt;input-&gt;post();
          $add=array(
          'name'=&gt;$post['sname'],
          'bio'=&gt;$post['bio']
          );
  
          $img1=$_FILES['photo']['name'];
         if($img1){
          $config['upload_path'] = 'images/singer/';
          $config['allowed_types'] = 'gif|jpg|png|jpeg';
  
          $this-&gt;load-&gt;library('upload', $config);
  
          if (!$this-&gt;upload-&gt;do_upload())
          {
              $error = $this-&gt;upload-&gt;display_errors();
              $this-&gt;session-&gt;set_flashdata('info',$error);
              redirect('admin/singer_manager');
          }
          $data = array('upload_data' =&gt; $this-&gt;upload-&gt;data());
          $image = $data['upload_data']['file_name'];
          $add['image']=$image;
  
          }
          else{
              $add['image']='no_image.jpg';
          }
  
          $table='tbl_singer';
          if($this-&gt;singer_manager-&gt;add($add,$table)){
           $this-&gt;session-&gt;set_flashdata('info',"Artist/Band Information Added Successfully.");
           redirect('admin/singer_manager');
          }
          else{
              redirect('admin/singer_manager');
          }
  
      }
      else{
      $data['main_content']='admin/singer/add_edit_singer_view';
      if($id != '')
              $data['editdata'] = $this-&gt;common_model-&gt;get_where('tbl_singer', array('id' =&gt; $id));
      $this-&gt;load-&gt;view('admin/include/template_view',$data);
    }
  </code></pre>
  
  <p>}</p>
  
  <p>my Model function is...</p>
  
  <pre><code>function add($data,$table){
      $name = $data['name'];
      $res = $this-&gt;db-&gt;insert($table,$data);
      if($res)
      {
          return true;
      }
      else
      {
          return false;
      }
  }
  </code></pre>
  
  <p>and my Form is...</p>
  
  <pre><code>&lt;form role="form" enctype="multipart/form-data" action="&lt;?php echo base_url('admin/singer_manager/add_edit_singer/' . $id); ?&gt;"
                            method="post"
                            id="user_form"&gt;
                          &lt;table class="table table-hover"&gt;
                              &lt;tr&gt;
                                &lt;td&gt;Singer Name&lt;/td&gt;
                                &lt;td&gt;
                                &lt;input type="text" class="form-control required" name="sname"
                                   value="&lt;?php if (isset($name)) {
                                       echo $name;
                                   } ?&gt;"/&gt;
                                &lt;/td&gt;  
                              &lt;/tr&gt;
  
                              &lt;tr&gt;
                                &lt;td&gt;Bio&lt;/td&gt;
                                &lt;td&gt;
                                  &lt;textarea class="form-control required" name="bio"&gt;
                                    &lt;?php if (isset($bio)) {
                                             echo $bio;
                                         } ?&gt;
                                  &lt;/textarea&gt;
                                &lt;/td&gt;
                              &lt;/tr&gt;
  
                              &lt;tr&gt;
                                &lt;td&gt;Image&lt;/td&gt;
                                &lt;td&gt;
                                &lt;?php if (isset($image)) {?&gt;
                                  &lt;div class="row"&gt;
                                    &lt;div class="col-xs-6 col-md-4"&gt;
                                      &lt;a href="&lt;?php echo base_url().'images/singer/'.$image;?&gt;" class="thumbnail"&gt;
                                        &lt;img src="&lt;?php echo base_url().'images/singer/'.$image;?&gt;" width="120" height="140" id="img_prev" /&gt;
                                      &lt;/a&gt;
                                    &lt;/div&gt;
                                  &lt;/div&gt;
                                &lt;?php
                                 } ?&gt;
  
                                &lt;input type="file"  name="photo" size="20" /&gt;
                                &lt;/td&gt;
                              &lt;/tr&gt;
  
                              &lt;tr&gt;
                                &lt;td colspan="2"&gt;
                                  &lt;?php if (isset($id)) { ?&gt;&lt;input type="hidden" name="id" value="&lt;?php echo $id; ?&gt;" /&gt;&lt;?php } ?&gt;
                                  &lt;input type="submit" class="btn btn-success" id="btn_save" name="save_singer_info"value="Save"/&gt;
                                  &lt;input type="reset" class="btn btn-info" id="reset"/&gt;
                                  &lt;input type="button" class="btn btn-danger" value="Cancel"onclick="history.go(-1)"/&gt;
                                &lt;/td&gt;
                              &lt;/tr&gt;
  
                          &lt;/table&gt;
                      &lt;/form&gt;
  </code></pre>