Create a zip file and download it

后端 未结 7 749
滥情空心
滥情空心 2020-11-29 04:16

I am trying to download a 2 files by creating the zip file on local-server.the file is downloaded in zip format but when i try to extract it.it gives error: End-of-

7条回答
  •  [愿得一人]
    2020-11-29 05:01

    // http headers for zip downloads
    header("Pragma: public");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: public");
    header("Content-Description: File Transfer");
    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=\"".$filename."\"");
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: ".filesize($filepath.$filename));
    ob_end_flush();
    @readfile($filepath.$filename);
    

    I found this soludtion here and it work for me

提交回复
热议问题