本文整理汇总了PHP中Zip::openStream方法的典型用法代码示例。如果您正苦于以下问题:PHP Zip::openStream方法的具体用法?PHP Zip::openStream怎么用?PHP Zip::openStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zip
的用法示例。
在下文中一共展示了Zip::openStream方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: while
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
if (strpos($file, ".php") !== false) {
$pathData = pathinfo($fileDir . $file);
$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";
}