title: How to upload multiple files in codeigniter 3.0.1
body: <p>How to upload multiple files in codeigniter 3.0.1. There are similar issues and solutions in stackoverflow but unfortunately non of them are helping to fix the issue I am facing.</p>
  
  <p>This is the error message appearing <code>You did not select a file to upload</code> with my current code</p>
  
  <p><strong>view (addGallery)</strong></p>
  
  <pre><code>&lt;section&gt;
      &lt;h2&gt;Add Gallery&lt;/h2&gt;
          &lt;?php echo form_open('Newsupload/gallery', ['id'=&gt;'news', 'name'=&gt;'news', 'method'=&gt;'post','enctype'=&gt;'multipart/form-data']) ?&gt;
  
          &lt;div class="grp width-50"&gt;
              &lt;label for="name"&gt;Album Name&lt;/label&gt;
              &lt;input type="text" name="name" id="name" value="" placeholder=""&gt;
          &lt;/div&gt;
          &lt;div class="grp width-100"&gt;
              &lt;div id="selectedFiles"&gt;&lt;/div&gt;
              &lt;input type="file" id="files" name="files[]" multiple size="20"&gt;&lt;br/&gt;
          &lt;/div&gt;
          &lt;?php if (isset($error)) {
              echo $error;
          } ?&gt;
          &lt;grp class="grp width-100"&gt;
              &lt;button&gt;Add&lt;/button&gt;
          &lt;/grp&gt;
      &lt;/form&gt;
  &lt;/section&gt;
  </code></pre>
  
  <p><strong>controller (gallery)</strong></p>
  
  <pre><code>public function gallery()
  {
  
      $this-&gt;load-&gt;library('upload');
  
      $files = $_FILES;
      $cpt = count($_FILES['files']['name']);
      for($i=0; $i&lt;$cpt; $i++)
      {           
          $_FILES['files']['name']= $files['files']['name'][$i];
          $_FILES['files']['type']= $files['files']['type'][$i];
          $_FILES['files']['tmp_name']= $files['files']['tmp_name'][$i];
          $_FILES['files']['error']= $files['files']['error'][$i];
          $_FILES['files']['size']= $files['files']['size'][$i];    
  
          $this-&gt;upload-&gt;initialize($this-&gt;set_upload_options());
          // $this-&gt;upload-&gt;do_upload('files[]');
          if (!$this-&gt;upload-&gt;do_upload('files[]'))
          {  
              $error =['error' =&gt; $this-&gt;upload-&gt;display_errors()];
              $this-&gt;load-&gt;view('admin/addGallery', $error);
          }
      }
  }
  public function set_upload_options()
  {
      $config['upload_path'] = getcwd().'/upload/';
      $config['allowed_types'] = 'gif|jpg|jpeg|png';
      $config['remove_spaces'] = true;
      return $config;
  }
  </code></pre>