title: Multiple image upload, resize and saveinto db using codeigniter
body: <p>I am trying to upload multiple image using codeigniter. here is the scenario
  <img src="https://i.stack.imgur.com/I541R.jpg" alt="enter image description here"></p>
  
  <p>How can i upload multiple image and save image location into db (cause i want to show uploaded image in my view file) and before upload I also want to rename my images and resize them into 'thumb' size.</p>
  
  <p>here is my controller:</p>
  
  <pre><code>    function uploadRoomImage(){
  
      $i = 0;
      $files = array();
      foreach ($_FILES as $key =&gt; $value) {
          if(!empty($value['name']))
          {
  
              $config['upload_path'] = 'assets/img/upload/rooms/';
              $config['allowed_types'] = 'jpg|jpeg';
              $config['file_name'] = $filename;
              $config['max_size'] = '2000';
              $config['remove_spaces'] = true;
              $config['overwrite'] = false;
  
              $this-&gt;upload-&gt;initialize($config);
  
              if (!$this-&gt;upload-&gt;do_upload($key))
              {
                  $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
              }
              else
              {
                  $files[$i] = $this-&gt;upload-&gt;data();
                  $i++;
  
                  //load image library
                  $this-&gt;load-&gt;library('image_lib');
  
                  $config['image_library'] = 'gd2';
                  $config['source_image'] = $image_data['full_path'];
                  $config['new_image'] = $image_data['file_path'].'room_thumb/';
                  $config['maintain_ratio'] = FALSE;
                  $config['create_thumb'] = TRUE;
                  $config['thumb_marker'] = '_thumb';
                  // $config['overwrite'] = false;
                  $config['width'] = 280;
                  $config['height'] = 280;
  
                  //initialize upload library using the config settings defined above.
                  $this-&gt;image_lib-&gt;initialize($config);
  
                  if (!$this-&gt;image_lib-&gt;resize()) {
                      $error = array('error' =&gt; $this-&gt;image_lib-&gt;display_errors());
                  } else {
                      $this-&gt;image_lib-&gt;resize();
                  }
                  //i want send each image file location into db in here after resizing each image
              }
          }           
      }       
  </code></pre>
  
  <p>i can upload multiple image but i cann't send their location into my db and i cannt resize them also. plz help</p>