0

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?

yosafat
  • 243
  • 1
  • 4
  • 17
  • i try but fail sir, any suggestion again – yosafat Oct 24 '16 at 07:30
  • 1
    You can't have multiple Content-Type headers, as it only allows [one to be passed to it](http://stackoverflow.com/questions/5809099/does-the-http-protocol-support-multiple-content-types-in-response-headers) and [you can only have duplicate headers if it supports a comma-delimited list for the field (which Content-Type doesn't)](http://stackoverflow.com/questions/4371328/are-duplicate-http-response-headers-acceptable). – Jack Wilsdon Oct 24 '16 at 14:34

1 Answers1

0

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');
marcus
  • 651
  • 6
  • 12