title: Upload multiple images with codeigniter
body: <p>I have used some code I found before to upload 1 image at a time and this works perfect. I would like to use the same style of code but for multiple images.</p>
  
  <p>The Model:</p>
  
  <pre><code> function cover_upload($afbeelding) {
      // path where the picture needs to be uploaded
      echo $album_path = APPPATH . 'images/covers';
      // configuration for the upload
      $ext = end(explode(".", $_FILES['userfile']['name']));
      $config = array(
          'file_name' =&gt; $afbeelding . '.' . $ext,
          'upload_path' =&gt; $album_path,
          'allowed_types' =&gt; 'gif|jpg|jpeg|png',
          'max_size' =&gt; '5120'
      );
      // load upload library with the configuration
      $this-&gt;load-&gt;library('upload', $config);
      // upload picture with the upload library
      if (!$this-&gt;upload-&gt;do_upload()) {
          echo $this-&gt;upload-&gt;display_errors();
          die();
      }
      // get data array of the uploaded picture
      $image_data = $this-&gt;upload-&gt;data();
      // configuration for the picture thumbnail resize
      echo $image_data['full_path'];
      $config = array(
          'source_image' =&gt; $image_data['full_path'],
          'new_image' =&gt; realpath($album_path . '/thumb'),
          'maintain_ration' =&gt; TRUE,
          'width' =&gt; 300,
          'height' =&gt; 300
      );
      // load image manupulation library with the configuration
      $this-&gt;load-&gt;library('image_lib', $config);
      // resize picture
      $this-&gt;image_lib-&gt;resize();
      $this-&gt;image_lib-&gt;clear();
      // submit file name of the uploaded picture to save it in the database
      $bestandsnaam = $image_data['file_name'];
      return $bestandsnaam;
  }
  </code></pre>
  
  <p>the view (just the part about the image):</p>
  
  <pre><code>&lt;div class="form-group"&gt;
              &lt;label class="col-sm-2 control-label" for="CoverFoto"&gt;picture&lt;/label&gt;
              &lt;div class="col-sm-5"&gt; 
                  &lt;div class="fileinput fileinput-new" data-provides="fileinput"&gt;
                      &lt;div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px;"&gt;&lt;/div&gt;
                      &lt;div&gt;
                          &lt;span class="btn btn-default btn-file"&gt;&lt;span class="fileinput-new"&gt;select_an_image&lt;/span&gt;&lt;span class="fileinput-exists"&gt;change&lt;/span&gt;&lt;input type="file" name="userfile"&gt;&lt;/span&gt;
                          &lt;a href="#" class="btn btn-default fileinput-exists" data-dismiss="fileinput"&gt;&lt;?php echo $this-&gt;lang-&gt;line("remove"); ?&gt;&lt;/a&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>And the controller:</p>
  
  <pre><code>if (!empty($_FILES['userfile']['name'])) {
              $gamma-&gt;CoverFoto = $this-&gt;gamma_model-&gt;cover_upload(url_title($gamma-&gt;Naam, '_', true));
          }
  </code></pre>
  
  <p>Is there a way to use this code so i can upload multiple images?</p>