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

前端 未结 6 1184
醉梦人生
醉梦人生 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:21

    Check out that each of your file exists before calling $zip->addFile otherwise the zip won't be generated and no error message will be displayed.

    if(file_exists($fichier->url))
    {
        if($zip->addFile($fichier->url,$fichier->nom))
        {
            $erreur_ouverture = false;
        }
        else
        {
            $erreur_ouverture = true;
            echo 'Open error : '.$fichier->url;
        }
    }
    else
    {
        echo 'File '.$fichier->url.' not found';
    }
    

提交回复
热议问题