Create a zip file and download it

后端 未结 7 750
滥情空心
滥情空心 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条回答
  •  -上瘾入骨i
    2020-11-29 05:02

    I just ran into this problem. For me the issue was with:

    readfile("$archive_file_name");
    

    It was resulting in a out of memory error.

    Allowed memory size of 134217728 bytes exhausted (tried to allocate 292982784 bytes)
    

    I was able to correct the problem by replacing readfile() with the following:

        $handle = fopen($zipPath, "rb");
        while (!feof($handle)){
            echo fread($handle, 8192);
        }
        fclose($handle);
    

    Not sure if this is your same issue or not seeing that your file is only 1.2 MB. Maybe this will help someone else with a similar problem.

提交回复
热议问题