ZipArchive call error :: close ()

0

When I'm using the close method to close the instance of ZipArchive I'm getting the following error:

  

ZipArchive :: close (): Read error: Is a directory

The code for my application where close is executed is this:

$solicitacoes = Remessa::with('solicitacoes')
                        ->findOrFail($id)
                        ->solicitacoes()
                        ->with('usuario')
                        ->get();

$zip = new \ZipArchive();

$zipName = tempnam(sys_get_temp_dir(), 'remessa_');

if ($zip->open($zipName, ZipArchive::CREATE) === true) {

    $filesWithProblems = [];
    $filesNormal = [];

    $dir = public_path('imagens');

    $remessaId = zero_fill($id, 4);

    foreach ($solicitacoes as $solicitacao) {


        if ($solicitacao->usuario->nivel_id == 12) {

            $filename = $dir . "/colaboradores/{$solicitacao->usuario->id}/{$solicitacao->foto}";
            $filenameInZip = "$remessaId/$solicitacao->foto";

        } else {

            $filename = $dir . "/{$solicitacao->usuario->matricula}/{$solicitacao->foto}";
            $filenameInZip = "$remessaId/$solicitacao->foto";


        }

        if (file_exists($filename)) {
            $zip->addFile($filename, $filenameInZip);
            $filesNormal[] = $filename;
        } else {
            $filesWithProblems[] = $filename;
        }
    }
}


$zip->close();

I wanted to understand what this message means!

    
asked by anonymous 30.01.2017 / 20:34

0 answers