No error when creating zip, but it doesn't get created

前端 未结 6 1223
醉梦人生
醉梦人生 2021-02-18 15:38

I wrote this code to create a ZIP file and to save it. But somehow it just doesn\'t show any error, but it doesn\'t create a ZIP file either. Here\'s the code:

$         


        
6条回答
  •  北荒
    北荒 (楼主)
    2021-02-18 16:16

    Probably apache or php has not got permissions to create zip archives in that directory. From one of the comments on ZipArchice::open:

    If the directory you are writing or saving into does not have the correct permissions set, you won't get any error messages and it will look like everything worked fine... except it won't have changed!

    Instead make sure you collect the return value of ZipArchive::close(). If it is false... it didn't work.

    Add an else clause to your if statement and dump $res to see the results:

    if($res === TRUE) {
        ...
    } else {
        var_dump($res);
    }
    

提交回复
热议问题