title: Codeigniter file download from phpmyadmin become unreadable
body: <p>When i download A file from my database table (users) the file will become unreadable. The image file will become invalid and the PDF file will failed to be loaded. The size of the downloaded file also will become 1 KB. </p>
  
  <p>Although at first i have successfully upload the file to the same table (users), so the file definitely is not 1kb. </p>
  
  <p><a href="https://i.stack.imgur.com/HYvPz.png" rel="nofollow noreferrer">Table(users)</a></p>
  
  <p><a href="https://i.stack.imgur.com/F1KDG.png" rel="nofollow noreferrer">Example of error when opening pdf file</a></p>
  
  <p>My Controller(Files.php)</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>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  class Files extends CI_Controller {
      
      function __construct() {
          parent::__construct();
          $this-&gt;load-&gt;model('user');
      }
      
      public function index(){
          $data = array();
          
          //get files from database
          $data['files'] = $this-&gt;user-&gt;getRows();
          
          //load the view
          $this-&gt;load-&gt;view('r_down', $data); //modell-&gt;view
      }
      
      public function download($id){
          if(!empty($id)){
              //load download helper
              $this-&gt;load-&gt;helper('download');
              
              //get file info from database
              $fileInfo = $this-&gt;user-&gt;getRows(array('id' =&gt; $id));
              
              //file path
              $file = 'uploads/files/'.$fileInfo['picture']; 
              //download file 
             force_download($file, '$data');//name file nk save
           //force_download($file,NULL);//name file nk save
          }
      }</code></pre>
  </div>
  </div>
  </p>
  
  <p>My View(r_down.php)</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>&lt;?php if(!empty($files)){ foreach($files as $frow){ ?&gt;
  &lt;div class="file-box"&gt;
      &lt;div class="box-content"&gt;
          &lt;h5&gt;&lt;?php echo $frow['name']; ?&gt;&lt;/h5&gt;
          &lt;div class="preview"&gt;
              &lt;embed src="&lt;?php echo base_url().'uploads/images/'.$frow['picture']; ?&gt;"&gt; &lt;!-- nk view apa letak dlm %frow, ikut nama column. directory ikut folder pc?--&gt;
          &lt;/div&gt;
          &lt;a href="&lt;?php echo base_url().'index.php/files/download/'.$frow['id']; ?&gt;" class="dwn"&gt;Download&lt;/a&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;?php } } ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Model(file.php)</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>function getRows($params = array()){
          $this-&gt;db-&gt;select('*');
          $this-&gt;db-&gt;from('users');
          $this-&gt;db-&gt;where('status','1');
          $this-&gt;db-&gt;order_by('created','email');
          if(array_key_exists('id',$params) &amp;&amp; !empty($params['id'])){
              $this-&gt;db-&gt;where('id',$params['id']);
              //get records
              $query = $this-&gt;db-&gt;get();
              $result = ($query-&gt;num_rows() &gt; 0)?$query-&gt;row_array():FALSE;
          }else{
              //set start and limit
              if(array_key_exists("start",$params) &amp;&amp; array_key_exists("limit",$params)){
                  $this-&gt;db-&gt;limit($params['limit'],$params['start']);
              }elseif(!array_key_exists("start",$params) &amp;&amp; array_key_exists("limit",$params)){
                  $this-&gt;db-&gt;limit($params['limit']);
              }
              //get records
              $query = $this-&gt;db-&gt;get();
              $result = ($query-&gt;num_rows() &gt; 0)?$query-&gt;result_array():FALSE;
          }
          //return fetched data
          return $result;
      }</code></pre>
  </div>
  </div>
  </p>