图片路径未上传到数据库 php codeigniter

Image Path not uploading into database php codeigniter

我正在尝试构建一个包含产品信息和图像的项目。我尝试了下面给出的一些代码,但我无法在数据库中上传图像路径。我是一个正在学习代码的新手。

控制器代码:-

class Category extends CI_Controller{
    public function __construct(){
        parent::__construct();
        $this->load->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->load->library('upload', $config);
    if (  ! $this->upload->do_upload('product_image')){
                $error = array('error' => $this->upload->display_errors());

                $this->load->view('admin/pages/add_product_form', $error);

    }     

                else
                {
                    $upload_data = $this->upload->data();

                    $this->Category_model->insert_data( $upload_data['upload_path']);

                }



        $data = array('upload_data' => $this->upload->data());

}
function  save_product(){
       $this->do_upload();

       $this->session->set_userdata('message','Product saved successfully');
       $this->add_product();

   }
}

型号代码:-

function insert_data( $path_name){
    $data = array(

                  'product_image'    => $path_name
                 );

    $data['product_status']=1;

    $this->db->insert('tbl_product', $data);


}

查看代码:-

 <form class="form-horizontal" action="<?php echo base_url()?>index.php/Category/save_product" enctype="multipart/form-data" method="post">

                <fieldset>
                    <div class="control-group">
                        <label class="control-label" for="typeahead">Product Name </label>
                        <div class="controls">
                            <input type="text" name="product_name" class="span6 typeahead" id="typeahead"  data-provide="typeahead" data-items="4" >

                        </div>
                    </div>




                                                        <div class="control-group">
                                <label class="control-label" for="selectError3">Product Category</label>
                                <div class="controls">
                                  <select name="product_category" id="selectError3">
                                                                      <option>Select Category</option>
                                                                      <?php foreach($category_info as $category){ ?>
                                                                        <option value="<?php echo $category->category_id ?>"><?php echo $category->category_name; ?></option>


                                                                   <?php } ?>   

                                    <option>Option 2</option>
                                    <option>Option 3</option>
                                    <option>Option 4</option>
                                    <option>Option 5</option>
                                  </select>
                                </div>
                              </div>

            <div class="control-group">
                        <label class="control-label" for="typeahead">Product Image </label>
                        <div class="controls">
            <input name="product_image" type="file" name="fileToUpload" id="fileToUpload">

                        </div>
            </div>
                    <div class="form-actions">
                        <button type="submit" class="btn btn-primary">Save changes</button>
                        <button type="reset" class="btn">Cancel</button>
                    </div>
                </fieldset>
            </form>   

这是我上面给出的代码,但仍然没有得到数据库中的图像路径,请提前帮助regard.Thanks。

刚刚增加了max_size、max_width、max_height这些就解决了问题。