title: Image Path not uploading into database php codeigniter
body: <p>I am trying to build a project with product information with image. I have tried some code given below, but I can not upload image path in the database. I am a newbie trying to learn code.</p>
  
  <p>controller code:-</p>
  
  <pre><code>class Category extends CI_Controller{
      public function __construct(){
          parent::__construct();
          $this-&gt;load-&gt;model('Category_model');
  
      }
  private function do_upload(){
      $config['upload_path']='./uploads/';
      $config['allowed_types']        = 'gif|jpg|png';
      $config['max_size']             = 1000;
      $config['max_width']            = 1024;
      $config['max_height']           = 768;
      $this-&gt;load-&gt;library('upload', $config);
      if (  ! $this-&gt;upload-&gt;do_upload('product_image')){
                  $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
  
                  $this-&gt;load-&gt;view('admin/pages/add_product_form', $error);
  
      }     
  
                  else
                  {
                      $upload_data = $this-&gt;upload-&gt;data();
  
                      $this-&gt;Category_model-&gt;insert_data( $upload_data['upload_path']);
  
                  }
  
  
  
          $data = array('upload_data' =&gt; $this-&gt;upload-&gt;data());
  
  }
  function  save_product(){
         $this-&gt;do_upload();
  
         $this-&gt;session-&gt;set_userdata('message','Product saved successfully');
         $this-&gt;add_product();
  
     }
  }
  </code></pre>
  
  <p>Model code:-</p>
  
  <pre><code>function insert_data( $path_name){
      $data = array(
  
                    'product_image'    =&gt; $path_name
                   );
  
      $data['product_status']=1;
  
      $this-&gt;db-&gt;insert('tbl_product', $data);
  
  
  }
  </code></pre>
  
  <p>view code:-</p>
  
  <pre><code> &lt;form class="form-horizontal" action="&lt;?php echo base_url()?&gt;index.php/Category/save_product" enctype="multipart/form-data" method="post"&gt;
  
                  &lt;fieldset&gt;
                      &lt;div class="control-group"&gt;
                          &lt;label class="control-label" for="typeahead"&gt;Product Name &lt;/label&gt;
                          &lt;div class="controls"&gt;
                              &lt;input type="text" name="product_name" class="span6 typeahead" id="typeahead"  data-provide="typeahead" data-items="4" &gt;
  
                          &lt;/div&gt;
                      &lt;/div&gt;
  
  
  
  
                                                          &lt;div class="control-group"&gt;
                                  &lt;label class="control-label" for="selectError3"&gt;Product Category&lt;/label&gt;
                                  &lt;div class="controls"&gt;
                                    &lt;select name="product_category" id="selectError3"&gt;
                                                                        &lt;option&gt;Select Category&lt;/option&gt;
                                                                        &lt;?php foreach($category_info as $category){ ?&gt;
                                                                          &lt;option value="&lt;?php echo $category-&gt;category_id ?&gt;"&gt;&lt;?php echo $category-&gt;category_name; ?&gt;&lt;/option&gt;
  
  
                                                                     &lt;?php } ?&gt;   
  
                                      &lt;option&gt;Option 2&lt;/option&gt;
                                      &lt;option&gt;Option 3&lt;/option&gt;
                                      &lt;option&gt;Option 4&lt;/option&gt;
                                      &lt;option&gt;Option 5&lt;/option&gt;
                                    &lt;/select&gt;
                                  &lt;/div&gt;
                                &lt;/div&gt;
  
              &lt;div class="control-group"&gt;
                          &lt;label class="control-label" for="typeahead"&gt;Product Image &lt;/label&gt;
                          &lt;div class="controls"&gt;
              &lt;input name="product_image" type="file" name="fileToUpload" id="fileToUpload"&gt;
  
                          &lt;/div&gt;
              &lt;/div&gt;
                      &lt;div class="form-actions"&gt;
                          &lt;button type="submit" class="btn btn-primary"&gt;Save changes&lt;/button&gt;
                          &lt;button type="reset" class="btn"&gt;Cancel&lt;/button&gt;
                      &lt;/div&gt;
                  &lt;/fieldset&gt;
              &lt;/form&gt;   
  </code></pre>
  
  <p>This is my code given above, but still not getting the image path in database, please help in this regard.Thanks in Advance.</p>