I'm using following code
<?php
$file = 'COMPANY_PROFILE.pdf';
if (! file) {
die('file not found'); //Or do something
} else {
// Set headers
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$file");
header("Content-Type: application/zip");
header("Content-Transfer-Encoding: binary");
// Read the file from disk
readfile($file);
}
This automatically gives a download file prompt and if i use something like this:
<a href="COMPANY_PROFILE.pdf" target="_blank" ">Download PDF </a>
it opens the PDF in the browser, so how do I fix this issue in a way that file gets downloaded on button click?