0
I am having difficulty to force a download of a file type kmz (google file Earth), it is made to download but the file gets corrupted, someone can 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.");
vc is closing the php tag(
?>
) ?– rray
yes, it is working with other file types with pdf, jpg , rar and other however kmz does not work
– Mayko Barbosa
Try to remove it if possible, sometimes extra characters are added with the closing tag which end up 'corrupting' the file.
– rray
remove closing tag?
– Mayko Barbosa
Yes, it has html after closing tag?
– rray
has no, it’s just this snippet of code and with the opening and closing php tags
– Mayko Barbosa
believe q the file is of unknown extension
– Mayko Barbosa
I have tried using Content-Type: Unknown/Unknown also failed
– Mayko Barbosa