title: How to download the xls file using codeigniter
body: <p>Here i have one button, if i click the button means i want to download the one demo.xls file,using php i did, but now i want to do codeigniter, i tried but i am not able to do? please see my below code</p>
  
  <pre><code>    &lt;button class="btn btn-warning" id="download-btn"&gt;
      &lt;i class="fa fa-download" aria-hidden="true"&gt;&lt;/i&gt;  Download Demo File
  &lt;/button&gt;
  
  
  &lt;script type="text/javascript"&gt;
  $(document).ready(function(){
  $("#download-btn").click(function(e){
    e.preventDefault();
       $.ajax({
               type:'POST',
               url :"Staff/downloadDemoFile",
               cache: false,
               contentType: false,
               processData: false,
               success: function(data) {
                   console.log(data);
               },
               error:function(exception){
               alert('Exeption:'+exception);
              }
            });
  
  
  });
  });
  &lt;/script&gt;
  </code></pre>
  
  <blockquote>
    <p>My controller</p>
  </blockquote>
  
  <pre><code>public function downloadDemoFile()
  {
      if($this-&gt;session-&gt;logged_in != TRUE){
          $this-&gt;load-&gt;view('login');
      }
      else{
      $download= $this-&gt;Add_staff_model-&gt;downloadFile();
      }
  }
  </code></pre>
  
  <blockquote>
    <p>My model</p>
  </blockquote>
  
  <pre><code>public function downloadFile()
      { 
              $sFileName = 'demo.xls';
              header("Cache-Control: public");
              header("Content-Description: File Transfer");
              header("Content-Disposition: attachment; filename=$sFileName");
              header("Content-Type: application/zip");
              header("Content-Transfer-Encoding: binary");
  
              // read the file from disk
              readfile(UPLOAD_PATH_XLS.$sFileName);
  
      }
  </code></pre>