PHP如何使用下载按钮下载文件tar.gz?

i have a code like this :

        header("Pragma: public", true);
        header("Expires: 0"); // set expiration time
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header('Content-type: application/rar');
        header("Content-Type: application/force-download");
        header("Content-Type: application/octet-stream");
        header('Content-Type: application/download');
        header('Content-Disposition: attachment; filename='.$fullname);
        header("Content-Transfer-Encoding: binary");
        header("Content-Length: " . filesize($fullname));
        $fp = fopen($fullname, "r");
        fpassthru($fp);
        fclose($fp);

based on above code, download is running, but the tar.gz cannot be opened. how to solve it? is it possible to download tar.gz?

Content type for GNU zipped archive is application/x-gzip. You should use below code to set content type

header('Content-type: application/x-gzip');