how to force kmz file download with php

0

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.");
    
asked by anonymous 13.07.2015 / 20:28

1 answer

0

Put this in your .htaccess file: AddType application / octet-stream .kmz

Then to download, just create a link or go to the URL pointing directly to your file. Ex: link

    
13.07.2015 / 21:20