Symfony2 create and download zip file

后端 未结 7 820
Happy的楠姐
Happy的楠姐 2020-12-15 06:51

I have one application that upload some files and then I can compress as zip file and download.

The export action:

public function exportAction() {
          


        
7条回答
  •  旧时难觅i
    2020-12-15 07:12

    solved:

    $zip->close();
    header('Content-Type', 'application/zip');
    header('Content-disposition: attachment; filename="' . $zipName . '"');
    header('Content-Length: ' . filesize($zipName));
    readfile($zipName);
    

    apparently closing the file is important ;)

提交回复
热议问题