How to download file via absolute path (for example, MS Excel 2007)

1. Define path and filename:

$excelName = 'example.xlsx';
$excelPath = "path/to/file/$excelName";

2. Add headers:

header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="'.$EXCELname.'"');
header('Cache-Control: max-age=0');

3. Read the file:

readfile( $excelPath );
return;

Note: <form></form> must be created, filled and submitted with target=”_blank” and method=”POST”.