PHP's ZipArchive does not work by command line

0

The script below does not work when I run via the command line. I am using XAMPP on Windows. Through the browser generates everything right. If anyone has any suggestions for improvement in the code.

$zip = new ZipArchive();

if($zip->open('Fevereiro.zip', ZIPARCHIVE::CREATE) == TRUE){
$open = opendir($diretorio_bkp);


        while ($pasta = readdir($open)) {

            if ($pasta != '.' && $pasta != '..') {

                if (is_dir($diretorio_bkp.$pasta.'/')) { 

                    $zip->addEmptyDir($pasta);

                    $listaarq = opendir($diretorio_bkp.$pasta);

                    while ($arquivo = readdir($listaarq)) {
                        if ($arquivo != '.' && $arquivo != '..') {

                                //echo $pasta.'/'.$arquivo.'<br>';
                                $zip->addFile($diretorio_bkp.$pasta.'/'.$arquivo, $pasta.'/'.$arquivo);

                        }

                    }       


                } 

            }
        }       


}

$zip->close();
    
asked by anonymous 13.03.2018 / 19:54

0 answers