title: How to update image data with form_upload in codeigniter
body: <p>How to edit this data with image inside.Data have been updated when i press the button "submit", but the old image can not change with the new image</p>
  
  <pre><code>if($this-&gt;input-&gt;post('go_upload'))
  {
  validation.......
  
  
  
  
  $IdPerumahan = $this-&gt;uri-&gt;segment(3);
  
          if ($this-&gt;form_validation-&gt;run() == TRUE)
          {
              $lokasi_file = $_FILES['userfile']['tmp_name'];
              $nama_file = $_FILES['userfile']['name'];
              $ukuran_file = $_FILES['userfile']['size'];
              $direktori_file = "./images/$nama_file";
  
              if (empty($lokasi_file)) 
              {
                  $this-&gt;load-&gt;model('PerumahanMDL');
                  $this-&gt;PerumahanMDL-&gt;SimpanUbahPerumahan($IdPerumahan); 
                  redirect('PerumahanCON');
  
              } else
              {
                  $config['upload_path'] = './images/';
                  $config['allowed_types'] = 'gif|jpg|png|bmp|jpeg|png';
                  $config['max_size'] = '2000';
                  $config['overwrite'] = 'true';
                  $config['max_width'] = '1024';
                  $config['max_height'] = '768';
  
                  $this-&gt;load-&gt;library('upload', $config);
                  $this-&gt;upload-&gt;initialize($config);
  
                  $field_name = "userfile";
                  if(!$this-&gt;upload-&gt;do_upload("userfile"))
                  { 
                      $data['data']= 'TambahPerumahanVW';
                      $this-&gt;load-&gt;view('Desain2',$data);
  
                  }else
                  {
  
                              $asdf = $this-&gt;upload-&gt;data();
                              $config = array(
                                  'source_image' =&gt; $asdf['full_path'],
                                  'new_image' =&gt; './images/thumb',
                                  'maintain_ration' =&gt; true,
  
                                  'width' =&gt; 180,
                                  'height' =&gt; 120
                          );
                          $this-&gt;load-&gt;library('image_lib', $config);
                          $this-&gt;image_lib-&gt;resize();
  
                          $userfile = $_FILES['userfile']['name'];    
                          $this-&gt;load-&gt;model('PerumahanMDL');
                          $this-&gt;PerumahanMDL-&gt;UbahDataPerumahan($userfile,$IdPerumahan); 
  
                          redirect('PerumahanCON');
  
                  }
              }
  
          }
          }
  }
  </code></pre>