title: How to update table with new image data using codeigniter
body: <p>I have a form to upload image-path and other image-data. This works well when I choose to upload a new image. </p>
  
  <p>How can I prevent that my image-path is set to blank if I submit my form without choosing a new image?</p>
  
  <p>here is my controller:</p>
  
  <pre><code>    function updatewaterpurifier($id)
      {
          $name=$this-&gt;input-&gt;post('name');
  
          $this-&gt;load-&gt;model('user');  
          //$name =  $this-&gt;input-&gt;post('name');
  
  
  
          if($this-&gt;input-&gt;post('submit'))
          {
  
          //Check whether user upload picture
              if(!empty($_FILES['picture']['name'])){
                  $new_file_name  = $this-&gt;input-&gt;post('name');
              $config['upload_path'] = 'uploads/images/';
              $config['allowed_types'] = 'jpg|jpeg|png|gif|pdf';
  
              $config['file_name'] = $new_file_name;
              $config['max_size']      = 2048;
              //Load upload library and initialize configuration
              $this-&gt;load-&gt;library('upload',$config);
              $this-&gt;upload-&gt;initialize($config);
  
              if($this-&gt;upload-&gt;do_upload('picture')){
                  $uploadData = $this-&gt;upload-&gt;data();
                  $picture = $uploadData['file_name'];
              }else{
                  $picture = '';
              }
          }else{
              $picture = '';
          }
              //Prepare array of user data
              $userData = array(
                  'product_brand'=&gt; $this-&gt;input-&gt;post('brand'),
                  'product_name' =&gt; $this-&gt;input-&gt;post('name'),
                  'product_price' =&gt; $this-&gt;input-&gt;post('price'),
                  'product_techno' =&gt; $this-&gt;input-&gt;post('technology'),
                  'product_des' =&gt; $this-&gt;input-&gt;post('description'),
                  'product_image' =&gt; $picture
              );
                  $this-&gt;db-&gt;where('id', $id);
                  $this-&gt;db-&gt;update('products', $userData);
              //Pass user data to model
  
  
              //Storing insertion status message.
  
          }
  
      //Form for adding user data
          $this-&gt;load-&gt;model('user'); 
          $this-&gt;data['h']= $this-&gt;user-&gt;editpurifier($id);
          $this-&gt;load-&gt;view('editwaterpurifier', $this-&gt;data, FALSE);
  
  
  
      }
  </code></pre>