title: Download Excel From Server Using PHP
body: <p>Can anyone help me to write code on PHP to download Excel File from the server.</p>
  
  <p>I have created below codes using <code>header</code> and <code>readfile</code> but the downloaded file was corrupted.</p>
  
  <pre><code>//content type
  header('Content-type: application/vnd.ms-excel');
  //open/save dialog box
  header('Content-Disposition: attachment; filename='.$fileName);
  //read from server and write to buffer
  readfile($reportPath);
  </code></pre>
  
  <p>Can anyone help me on the best way to download existing Excel file from the server.</p>
  
  <p>Please see below image of data after downloaded<img src="https://i.stack.imgur.com/ckjdw.png" alt="enter image description here"></p>