繁体   English   中英

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

[英]PHP How to download file tar.gz using download button?

我有这样的代码:

        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);

根据上述代码,下载正在运行,但无法打开tar.gz。 怎么解决呢? 可以下载tar.gz吗?

GNU压缩存档的内容类型为application / x-gzip。 您应该使用以下代码设置内容类型

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM