title: Multiple files upload in Codeigniter
body: <p>I want to upload multiple files using single element. So I try this example. </p>
  
  <p><a href="https://stackoverflow.com/questions/11524356/multiple-files-upload-array-with-codeigniter-2-0">Multiple files upload (Array) with CodeIgniter 2.0</a></p>
  
  <p>This is my form</p>
  
  <pre><code>&lt;form enctype="multipart/form-data" class="jNice" accept-charset="utf-8" method="post" action="http://xxxx.dev/admin/add_estates"&gt;              
      &lt;fieldset&gt;      
              &lt;label&gt;Title * : &lt;/label&gt;                       
              &lt;input type="text" class="text-long" value="" name="title"&gt;
  
              &lt;label&gt;Description : &lt;/label&gt;                       
              &lt;textarea class="mceEditor" rows="10" cols="40" name="description"&gt;&lt;/textarea&gt;
  
              &lt;label&gt;Image : &lt;/label&gt;                     
              &lt;input type="file" multiple="" name="images[]"&gt;                             
  
              &lt;button class="button-submit" type="submit" name="save" id=""&gt;Save&lt;/button&gt;
      &lt;/fieldset&gt;         
  &lt;/form&gt;
  </code></pre>
  
  <p>This is my controller </p>
  
  <pre><code>public function add_estates()
  {
      $data['page_title'] = "&amp;copy; IDEAL - Administrator - Real State - Add Real Estate";
      $data['main_content'] = 'admin/add_estates';
  
      if ($this-&gt;input-&gt;post() !== FALSE) {           
          $this-&gt;load-&gt;library('form_validation');
          $this-&gt;form_validation-&gt;set_rules('title', 'Career Title', 'trim|required');           
  
          if ($this-&gt;form_validation-&gt;run() !== FALSE) {                
  
              $title = $this-&gt;input-&gt;post('title');
              $description = $this-&gt;input-&gt;post('description');
  
              if (!empty($_FILES['images']['name'][0])) {
                  if ($this-&gt;upload_files($title, $_FILES['images']) === FALSE) {
                      $data['error'] = $this-&gt;upload-&gt;display_errors('&lt;div class="alert alert-danger"&gt;', '&lt;/div&gt;');
                  }
              }                   
  
              if (!isset($data['error'])) {
                  $this-&gt;admin_model-&gt;add_estate($title, $description, $image_name);    
                  $this-&gt;session-&gt;set_flashdata('suc_msg', 'New real estate added successfully'); 
                  redirect('admin/add_estates');    
              }          
          }
      }
  
      $data['suc_msg'] = $this-&gt;session-&gt;flashdata('suc_msg');
  
      $this-&gt;load-&gt;view('layout_admin', $data);
  }
  </code></pre>
  
  <p>This is my file upload method</p>
  
  <pre><code>private function upload_files($title, $files)
  {
      $config = array(
          'upload_path'   =&gt; './upload/real_estate/',
          'allowed_types' =&gt; 'jpg|gif|png',
          'overwrite'     =&gt; 1,                       
      );
  
      $this-&gt;load-&gt;library('upload', $config);
  
      foreach ($files['name'] as $key =&gt; $image) {
          $_FILES['images']['name']= $files['name'][$key];
          $_FILES['images']['type']= $files['type'][$key];
          $_FILES['images']['tmp_name']= $files['tmp_name'][$key];
          $_FILES['images']['error']= $files['error'][$key];
          $_FILES['images']['size']= $files['size'][$key];
  
          $config['file_name'] = $title .'_'. $image;
  
          $this-&gt;upload-&gt;initialize($config);
  
          if ($this-&gt;upload-&gt;do_upload($image)) {
              $this-&gt;upload-&gt;data();
          } else {
              return false;
          }
      }
  
      return true;
  }
  </code></pre>
  
  <p>But it give <code>You did not select a file to upload.</code> every time. What is the issue?</p>