How to create a ZIP file from multiple files in PHP ?

I would like to ask to suggest, how I can create compressed ZIP file with more files, by using PHP.
08 Jun 2019 at 07:36 PM
0pnshow more

To create a ZIP file with more files, you can use the solution below. ZIP file will include image_1.jpg and image_2.jpg (renamed source files: file_1.jpg and file_2.jpg).

$zip = new ZipArchive();
$zipfilename = "";

if ($zip->open($zipfilename, ZipArchive::CREATE)===TRUE) {
echo "ZIP file created";
else {
echo "Cannot open " . $zipfilename ;

You can add more files into ZIP archive by including another addFile functions in the source.
14 Jun 2019 at 01:31 PM
0pnshow more
Share on FacebookShare on TwitterShare on LinkedInSend email
Follow us on Facebook & Twitter
2022 AnswerTabsTermsContact us