$fileName = $pathData['filename']; $zip->addFile(file_get_contents($fileDir . $file), $file, filectime($fileDir . $file), NULL, TRUE, Zip::getFileExtAttr($file)); } } } // Uses my Lipsum generator from https://github.com/Grandt/PHPLipsumGenerator if(file_exists('./LipsumGenerator.php')) { require_once './LipsumGenerator.php'; $lg = new com\grandt\php\LipsumGenerator(); $zip->openStream("big one3.txt"); for ($i = 1 ; $i <= 20 ; $i++) { $zip->addStreamData("Chapter $i\r\n\r\n" . $lg->generate(300, 2500) . "\r\n"); } $zip->closeStream(); } $zip->sendZip("ZipExample3.zip", "application/zip", "ZipExample3.zip"); // If non-fatal errors occured during execution, this will append them // to the end of the generated file. // It'll create an invalid Zip file, however chances are that it is invalid // already due to the error happening in the first place. // The idea is that errors will be very easy to spot. if (!empty($errors)) { echo "\n\n**************\n*** ERRORS ***\n**************\n\n$errors"; } function customError($error_level, $error_message, $error_file, $error_line) { global $errors; switch ($error_level) {