So I am having this problem wit my download link. Basically my previous way of creating download link is to just have a form button with method=\'link\' and the action to be the
Something like this works fine.
header("Pragma: public", true);
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=".basename($file));
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($file));
die(file_get_contents($file));
If I understand you correctly the script is working as expected, i.e if a browser recognizes mime type:
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
Then it SHOWS it in browser (whether or not it displays correctly is something else)
Since you want to FORCE it to download INSTEAD OF showing in browser use the mime type:
'application/octet-stream'
This should work in all browsers and force the download instead of display in browser.