title: Multiple image upload with CodeIgniter
body: <p>I am new user to using code igniter in my project, I am facing one problem while uploading multiple files but the last one only insert to all image three images field.</p>
  
  <p>my controller is:</p>
  
  <pre><code>function products()
      {
       date_default_timezone_set("Asia/Kolkata");
       $config['upload_path'] = './resources/images/products/';
       $config['allowed_types']        = 'gif|jpg|png';
       $config['max_size']             = 1000;
       $config['max_width']            = 1024;
       $config['max_height']           = 768;
       $this-&gt;load-&gt;library('upload', $config);
       $this-&gt;upload-&gt;do_upload('userfile');
          $data = array('prod_image' =&gt; $this-&gt;upload-&gt;data(), 
               'prod_image1' =&gt; $this-&gt;upload-&gt;data(),
                'prod_image2' =&gt; $this-&gt;upload-&gt;data());
      $product_image=$data['prod_image']['file_name']; 
      $product_image1=$data['prod_image1']['file_name'];
      $product_image2=$data['prod_image2']['file_name'];
  
          $data = array(
                  'name' =&gt; $this-&gt;input-&gt;post('pd_name'),
                  'prod_image' =&gt; $product_image,
                  'prod_image1' =&gt; $product_image1,
                  'prod_image2' =&gt; $product_image2,
                  'created_time' =&gt; date('Y-m-d H:i:s'));
  
          // insert form data into database
          $result_set= $this-&gt;tbl_products_model-&gt;insertUser($data);
  
      }       
  </code></pre>
  
  <p>my view part is:</p>
  
  <pre><code>&lt;input class="form-control" name="pd_name"type="text"/&gt;
  &lt;input type="file"  class="file_upload2" name="userfile"/&gt; //1
  &lt;input type="file" class="file_upload2" name="userfile"/&gt; //2
  &lt;input type="file" class="file_upload2" name="userfile"/&gt;//3
  </code></pre>
  
  <p>Please help how to insert 3 images.</p>
  
  <p>my datad base like</p>
  
  <pre><code>===========================================
  id|name|prod_image|prod_image1|prod_image2|
  ===========================================
   1|ard|           |           |          |
  ============================================
  </code></pre>