title: CodeIgniter multiple image upload and resize
body: <p>As i am beginner in PHP so i am facing difficulty even after the help of tutorials.
  My code upload the multiple pictures but it re-size only 1st Picture and rest of the pictures remain same as they are uploaded.
  I have tried unset and clear() but problem is same.
  I will really appreciate if some one will help me to resolve this problem.</p>
  
  <pre><code>function do_upload()
      {    
          $files = $_FILES;    
          $cpt = count($_FILES['userfile']['name']);
  
          for($i=0; $i&lt;$cpt; $i++)
          {
  
              $_FILES['userfile']['name']= $files['userfile']['name'][$i];
              $_FILES['userfile']['type']= $files['userfile']['type'][$i];
              $_FILES['userfile']['tmp_name']= $files['userfile']['tmp_name'][$i];
              $_FILES['userfile']['error']= $files['userfile']['error'][$i];
              $_FILES['userfile']['size']= $files['userfile']['size'][$i];
  
              $config['upload_path'] = './uploads/';
              $config['allowed_types'] = 'gif|jpg|png';
              $config['max_size']    = '2000';
              $config['max_width']   = '1024';
              $config['max_height']  = '768';
  
              $this-&gt;load-&gt;library('upload', $config);
  
              if ( ! $this-&gt;upload-&gt;do_upload())
              {
                  $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());    
                  $this-&gt;load-&gt;view('upload_form', $error);
              }
              else
              {
                  $data = array('upload_data' =&gt; $this-&gt;upload-&gt;data());    
                  $path=$data['upload_data']['full_path'];
                  $q['name']=$data['upload_data']['file_name'];
  
                   $configi['image_library'] = 'gd2';
                   $configi['source_image']   = $path;
                   $configi['maintain_ratio'] = TRUE;
                   $configi['width']  = 75;
                   $configi['height'] = 50;
  
                  $this-&gt;load-&gt;library('image_lib', $configi);    
                  $this-&gt;image_lib-&gt;resize();
  
                  $this -&gt; load -&gt; view('upload_success', $q);
                  unset($configi);
                  $this-&gt;load-&gt;library('image_lib');
                  $this-&gt;image_lib-&gt;clear(); }}}
  </code></pre>