Php Compress Files Into Zip
Hello there okay so this is the deal i have a folder where my mp3 files are stored for single download, and now i want a feature where you can download all the mp3s at once in a zi
Solution 1:
Just to demonstrate use of the undocumented addGlob() method of the zipArchive class:
$zipFile = dirname(__FILE__)."/myMP3s.zip";
$zipArchive = new ZipArchive();
if (!$zipArchive->open($zipFile, ZIPARCHIVE::OVERWRITE))
die("Failed to create archive\n");
$zipArchive->addGlob(dirname(__FILE__)."/*.mp3");
if (!$zipArchive->status == ZIPARCHIVE::ER_OK)
echo"Failed to write local files to zip\n";
$zipArchive->close();
Solution 2:
There are several PHP libraries for compression. Have you tried them?
Solution 3:
http://php.net/manual/en/book.zip.php
Mark Baker's example looks good, read up if you want to learn or need something more specific.
Post a Comment for "Php Compress Files Into Zip"