title: readfile return open stream: HTTP request failed! HTTP/1.1 403 Forbidden in php
body: <p>I have create one function in Codeigniter controller for download file, here is code for that.</p>
  
  <pre><code>function download_example($file_name) {
      header('Content-Type: application/octet-stream');
      header('Content-Disposition: attachment; filename='.$file_name);
      ob_clean();
      flush();
      readfile(base_url().'download_example/'.$file_name);
  } 
  </code></pre>
  
  <p>But after download in file show <strong>403 Forbidden error</strong> like this.</p>
  
  <blockquote>
    
    
    A PHP Error was encountered
    
    <p>Severity: Warning</p> <p>Message: 
    readfile(http://example.com/download_example/example.txt): failed to
    open stream: HTTP request failed! HTTP/1.1 403 Forbidden </p>
    <p>Filename: controllers/controllers.php</p> <p>Line Number: 371</p>
    
    
  </blockquote>