title: Update picture/image in Codeigniter
body: <p>I'm trying to create update image for user who want to change their photo.The when i click submit on photo upload, there is no photo uploaded and photo's column still no update.</p>
  
  <p>Here is my Contorller:</p>
  
  <pre><code>function foto($id='')
      {
          $data['data']        = $this-&gt;user_model-&gt;get_foto($id);
          $data['form_action'] = site_url("user/update_foto/$id");
          $this-&gt;load-&gt;view('user/foto_form', $data);
      }
  
      function update_foto($id=''){
          $this-&gt;user_model-&gt;update_foto($id);
      }
  </code></pre>
  
  <p>Here is My model:</p>
  
  <pre><code>function get_foto($id=0){
          $id    = $this-&gt;session-&gt;userdata('id');
          $sql   = "SELECT id,foto FROM user WHERE id= '$id'";
          $query = $this-&gt;db-&gt;query($sql);
          $data  = $query-&gt;row_array();
          return $data;
      }
  
      function update_foto(){
          $config['upload_path'] = './upload/';
          $config['allowed_types'] = 'jpg|png|jpeg';
          $this-&gt;load-&gt;library('upload', $config);
          if (!$this-&gt;upload-&gt;do_upload('foto'))
          {
              $id_user=$this-&gt;session-&gt;userdata('id');
              redirect ("user/foto/$id_user");
          }   else {
              $id_user=$this-&gt;session-&gt;userdata('id');
              $data=array(
              'foto'=&gt;$this-&gt;input-&gt;post('foto')
              );
              $this-&gt;db-&gt;where('id',$id_user);
              $this-&gt;db-&gt;update('user',$data);
              redirect("user");
          }
      }
  </code></pre>
  
  <p>And this is my upload form on view:</p>
  
  <pre><code>    &lt;form role="form" action="&lt;?php echo $form_action ?&gt;" class="form-horizontal style-form" method="POST" enctype="multipart/form-data"&gt;
      &lt;label &gt;Upload Foto&lt;/label&gt;
      &lt;input type="file" name="foto"/&gt;
    &lt;button type="submit"&gt;Save&lt;/button&gt;
     &lt;/form&gt;
  </code></pre>
  
  <p>Any Answer? Many thanks for the answer...</p>