I'm having trouble forcing a download of a file type kmz (google earth file), but the file gets corrupted, can anyone help me?
$filename = "../kmz/".$_GET['id'];
$filename = realpath($filename);
$file_extension = strtolower(substr(strrchr($filename,"."),1));
if (!file_exists($filename)) {
die("NO FILE HERE");
}
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=\"".basename($filename)."\";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".@filesize($filename));
set_time_limit(0);
@readfile("$filename") or die("File not found.");