I am trying to download a zip file from /tmp folder in Ubuntu. However when I run the Php code it shows garbage text on the browser instead of showing a download box. I tried with a simple text file and instead of showing me a download dialog box it printed its contents on the browser. Why this force-download isn't working. Below is the code.
if (file_exists($dir.$filename)) {
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($dir.$filename));
header('Content-disposition: attachment; filename='.basename($dir.$filename));
readfile($dir.$filename);
exit(0);
}
`