PHP code example of jdwil / zip-stream
1. Go to this page and download the library: Download jdwil/zip-stream library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jdwil / zip-stream example snippets
$xslt
$zipStream = ZipStream::forFile('/path/to/file.zip');
$zipStream->beginFile('foo.txt');
while ($data = $somePdoStatement->fetch()) {
$zipStream->addFilePart(implode(',', $data));
}
$zipStream->endFile();
$zipStream->close();
$xslt
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="foo.zip"');
header('Content-Transfer-Encoding: binary');
$zipStream = ZipStream::forFile('php://output');
// Build your zip file
$zipStream->close();