In this example, I will explain how to create a zip file of multiple files using PHP.

Create below function to create a zip file from multiple files.

The above function takes two arguments, $files – an array of files with full path and $zipName – the zip file name that has extension .zip.

Usage example

Here I will show you how to use the above function to create an archive or zip file.

So first the a.jpg and b.jpg are kept into folder 'uploads' and $files array is built using those files.
Then I define a $zipName using current time so every time a unique zip name is generated.
Then I simply call the createZipFromFiles() function to create the zip file.

Thanks for reading.

Software Professional, I am passionate to work on web/enterprise application. For more information please go to about me. You can follow on Twitter. You can be a friend on Facebook or Google Plus or Linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.