title: How to update image in CodeIgniter
body: <p>I am new in codeigniter. 
      I am using codeigniter for this project. 
      I have not getting how to update image form data in the database.
      I have inserting ,showing data in the database is done . 
      but i cant understand how to update image in the database. 
      This is a method which i use to update existing images but i am unable to 
      update image. 
      I have successfully uploaded image in my database.</p>
  
  <pre><code>public function update($id) {
      $this-&gt;form_validation-&gt;set_rules('tite', 'title', 'required');
      $this-&gt;form_validation-&gt;set_rules('slug', 'Slug', 'required');    
      if ($this-&gt;form_validation-&gt;run() === FALSE) {
          $data['category'] = $this-&gt;category_model-&gt;all();
          $this-&gt;load-&gt;view('backend/templates/header');
          $this-&gt;load-&gt;view('backend/templates/navigation');
          $this-&gt;load-&gt;view('backend/pages/edit', $data);
          $this-&gt;load-&gt;view('backend/templates/footer');  
      } else {
          if (!empty($_FILES['userfile']['name'])) {              
              // upload featured image
              $config['upload_path'] = './uploads/page';
              $config['allowed_types']    = 'gif|jpg|jpeg|png';
              $config['max_size'] = '2048';
              $config['max_width'] = '1080';
              $config['max_height'] = '768';
              $this-&gt;load-&gt;library('upload', $config);                
              if ( ! $this-&gt;upload-&gt;do_upload('userfile')) {
                  $data['page'] = $this-&gt;page_model-&gt;find($id);
                  $data['category'] = $this-&gt;category_model-&gt;all();
                  $data['error'] = $this-&gt;upload-&gt;display_errors();
                  $this-&gt;load-&gt;view('backend/templates/header');
                  $this-&gt;load-&gt;view('backend/templates/navigation');
                  $this-&gt;load-&gt;view('backend/pages/edit', $data);
                  $this-&gt;load-&gt;view('backend/templates/footer');
              } else {
                  $data = array('upload_data' =&gt; $this-&gt;upload-&gt;data());
                  $featured_img = $_FILES['userfile']['name'];
                  var_dump($data);
                  var_dump($featured_img);
              }
          } else {
  
              $this-&gt;page_model-&gt;update($featured_img, $id);
              redirect('backend/page', 'refresh');    
          }    
      }
  }
  </code></pre>
  
  <p>This is a method which i use to update existing images but i am unable to update image.
      This is a model where i send data. 
      I have successfully uploaded image in my database. </p>
  
  <pre><code>public function update($featured_img, $id) {
      $data = array(
          'title' =&gt; ucwords($this-&gt;input-&gt;post('title')),
          'slug' =&gt; strtolower($this-&gt;input-&gt;post('slug')),
          'content' =&gt; $this-&gt;input-&gt;post('content'),
          'featured_img' =&gt; $featured_img,
          'category_id' =&gt; $this-&gt;input-&gt;post('category_id')
      );
      $this-&gt;db-&gt;where('id', $id);
      return $this-&gt;db-&gt;update('pages', $data);
  }
  </code></pre>