inserting image path to database in codeigniter
<p>i have a form which have text fields and single image, the text field are inserting to the database successfully but image path is not inserting in database which i have stored in image variable, i am using mysql database, the image is uploading in folder but the path is not storing in database.</p>

<p><strong>The Controller File</strong></p>

<pre><code>class product{
function validate_products()
{


        $this-&gt;form_validation-&gt;set_rules('title', 'title', 'trim|required|');
        $this-&gt;form_validation-&gt;set_rules('price', 'price', 'trim|required');
        $this-&gt;form_validation-&gt;set_rules('description', 'description', 'trim|required');
        $this-&gt;form_validation-&gt;set_rules('category', 'category', 'trim|required');
        //$this-&gt;form_validation-&gt;set_rules('image', 'image', 'trim|required');

        $config = array(
        'upload_path' =&gt; "./images/",
        'allowed_types' =&gt; "gif|jpg|png|jpeg",
        'overwrite' =&gt; false,
        );  



$this-&gt;load-&gt;library('upload', $config);



        if($this-&gt;form_validation-&gt;run() &amp;&amp; $this-&gt;upload-&gt;do_upload() )
        {

            $data =  $this-&gt;upload-&gt;data();
            $image= base_url("images/". $data['raw_name'] . $data['file_ext']);

            $post['image'] = $image;



            $this-&gt;load-&gt;model('upload_model');

            if($query= $this-&gt;upload_model-&gt;create_product())
            {
                $this-&gt;session-&gt;set_flashdata('product_sucsess', 'Product uploaded sucsessfully');
                $this-&gt;upload();

            }
            else
            {


                $this-&gt;session-&gt;set_flashdata('product_fail', 'Sorry product not uploaded .');
                $this-&gt;load-&gt;view('Admin/upload_product');

            }


        }
        else
        {

            $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
            $this-&gt;load-&gt;view('admin/upload_product', $error);


        }
        }
}
</code></pre>



<p><strong>The Model class</strong></p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>class upload_model extends  CI_Model
{
 public function __construct() 
     {
           parent::__construct(); 
           $this-&gt;load-&gt;database();
     }

 
 
 function create_product()
 {
  $new_member_insert_data = array(
  'title'=&gt; $this-&gt;input-&gt;post('title'),
  'image'=&gt; $this-&gt;input-&gt;post('image'),
  'price'=&gt; $this-&gt;input-&gt;post('price'),
  'description'=&gt; $this-&gt;input-&gt;post('description'),
  'category'=&gt; $this-&gt;input-&gt;post('category'));
  
  $insert = $this-&gt;db-&gt;insert('product', $new_member_insert_data);
  return true;
 }
 
}</code></pre>
</div>
</div>
</p>