title: inserting image in mysql db using codeigniter
body: <p>I am trying to store image in mysql using codeigniter.
  Data is getting successfully inserted but i am not able to view that image.</p>
  
  <pre><code>enter code here
  $this-&gt;gallery_path = realpath(APPPATH . '../img');
      $config=array(
          'allowed_types' =&gt; 'jpg|jpeg|gif|png',
          'upload_path' =&gt; $this-&gt;gallery_path,
          'max_size' =&gt;2000
      );
      $this-&gt;load-&gt;library('upload',$config);
  
      $this-&gt;upload-&gt;do_upload('business_icon');
  
      $upload_data = $this-&gt;upload-&gt;data();
  
          $data_ary = array(
              'title'     =&gt; $upload_data['client_name'],
              'file'      =&gt; $upload_data['file_name'],
              'width'     =&gt; $upload_data['image_width'],
              'height'    =&gt; $upload_data['image_height'],
              'type'      =&gt; $upload_data['image_type'],
              'size'      =&gt; $upload_data['file_size'],
              'date'      =&gt; time(),
          );
  
          $image_data=fopen($this-&gt;gallery_path.'/'.$upload_data['file_name'],'rb');
          $image_data1= fread($image_data,$upload_data['file_size']);
  
          $image_type='image/'.$upload_data['image_type'];
  
  
  
      $insert_data=array(
          'business_name'=&gt;$this-&gt;input-&gt;post('business_name'),
          'business_icon'=&gt;$image_data1,
          'icon_type'=&gt;$image_type,
      );  
  
      $this-&gt;db-&gt;insert('businesses',$insert_data);
      return $this-&gt;db-&gt;insert_id();
  </code></pre>
  
  <p>Can any one help me on this how can i store image in db and also read it in codeigniter.</p>