Dynamically creating zip with php
php
Solution
See the ZipArchive class; it has what you need.
http://www.php.net/manual/en/class.ziparchive.php
Example from PHP.Net:
<?php
$zip = new ZipArchive;
if ($zip->open('test.zip') === TRUE) {
$zip->addFile('/path/to/index.txt', 'newname.txt');
$zip->close();
echo 'ok';
} else {
echo 'failed';
}
?>
After zipping it, you can output a mime-type header and output the file:
header('Content-type: application/zip');
readfile('test.zip');
Problem
What is the easiest way of creating dynamically zip files with php? For example, I have these files on the server, ``` Root -> Folder 1 -> file1.wav Root -> Folder 2 -> file2.jpg ``` I want to create a zip file contains these 2 files and allow user to download it. any help ? Thx in advance