title: Codeigniter: how to edit form without edit image input
body: <p>I need a small help to figure out the edit page.</p>
  
  <p>I have the Insert data and Edit data.</p>
  
  <p>On edit data is requesting also the form for file/image upload, and on submit this send the null to the column file/image.</p>
  
  <p>What i need is that on edit if no new file is on file/image input to skip this input.</p>
  
  <p>This is my controller to insert and edit data.</p>
  
  <pre><code>// Set up the form
          $rules = $this-&gt;image_m-&gt;rules;
          $this-&gt;form_validation-&gt;set_rules($rules);
  
          // Upload File Image
          $status = "";
          $msg = "";
          $file_element_name = 'file_name';
  
          if ($status != "error")
          {
            $config['upload_path'] = './uploads/images/';
            $config['allowed_types'] = 'gif|jpg|png|doc|txt';
            $config['max_size']   = '2000';
            $config['max_width']  = '1024';
            $config['max_height']  = '768';
            $config['encrypt_name'] = FALSE;
            $config['remove_spaces'] = TRUE;
  
            $this-&gt;load-&gt;library('upload', $config);
  
            if (!$this-&gt;upload-&gt;do_upload($file_element_name))
            {
               $status = 'error';
               $msg = $this-&gt;upload-&gt;display_errors('', '');
            }
            else
              {
               $image = $this-&gt;upload-&gt;data();
               }
            }
  
  
  
          // Process the form
          if ($this-&gt;form_validation-&gt;run() == TRUE) {
              $data = array(
                  'pubdate' =&gt; $this-&gt;input-&gt;post('pubdate'),
                  'enddate' =&gt; $this-&gt;input-&gt;post('enddate'),
                  'name' =&gt; $this-&gt;input-&gt;post('name'),
                  'image'     =&gt; $image['file_name']
              );
              $this-&gt;image_m-&gt;save($data, $id);
              redirect('admin/image');
          }
  </code></pre>
  
  <p>Any help is appreciated.</p>
  
  <p>Solution:</p>
  
  <pre><code>// Process the form
          if ($this-&gt;form_validation-&gt;run() == TRUE) {
              if(is_null($image['file_name'])){
              $data = array(
                  'pubdate' =&gt; $this-&gt;input-&gt;post('pubdate'),
                  'enddate' =&gt; $this-&gt;input-&gt;post('enddate'),
                  'name' =&gt; $this-&gt;input-&gt;post('name'),
                  'caption' =&gt; $this-&gt;input-&gt;post('caption')
              );
              } else {
              $data = array(
                  'pubdate' =&gt; $this-&gt;input-&gt;post('pubdate'),
                  'enddate' =&gt; $this-&gt;input-&gt;post('enddate'),
                  'name' =&gt; $this-&gt;input-&gt;post('name'),
                  'image'     =&gt; $image['file_name'],
                  'caption' =&gt; $this-&gt;input-&gt;post('caption')
              );
              }
  </code></pre>