title: How to store the file in mysql database using codeigniter?
body: <p>I have created a simple  contact form.I want to store the file in database which is uploaded by any user.I am able to store the file in my folder but i have to store the file in database to identify the admin  which file is upload.</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public function index()
          {
                  $this-&gt;load-&gt;view('demo', array('error' =&gt; ' ' ));
          }
  
   public function do_upload()
          {
  
  
                  $id = $this-&gt;session-&gt;userdata('id');
                  $this-&gt;load-&gt;model('Model_doc');
  
                  $config['upload_path']          = './upload/';
                  $config['allowed_types']        = 'docx';
                  $config['max_size']             = 1000;
                  $config['max_width']            = 1024;
                  $config['max_height']           = 768;
  
                  $this-&gt;load-&gt;library('upload', $config);
  
                  $this-&gt;upload-&gt;do_upload();
                  $this-&gt;Model_doc-&gt;index($id, $this-&gt;upload-&gt;data());
     } 
  </code></pre>
  
  <p><strong>Model</strong></p>
  
  <pre><code>public function index($id,$imgdata)
  
  {
  
  
   $imgdata = file_get_contents($imgdata['../upload/']);
  
  $data = array(
          'path'=&gt;$imgdata,
  
           );
      $this-&gt;db-&gt;set('curentDate', 'NOW()', FALSE);
   $this-&gt;db-&gt;insert('test',$data);
  
  }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;?php echo form_open_multipart('welcome/do_upload');?&gt;
  
  &lt;input type="file" name="userfile" size="20" /&gt;
  
  &lt;br /&gt;&lt;br /&gt;
  
  &lt;input type="submit" value="upload" /&gt;
  
  &lt;/form&gt;
  </code></pre>