Wednesday 26 September 2018

Create a Zip File Using PHP and Download Multiple Files

Today i am sharing how to create a zip file of multiple files using PHP and download that zip file on click. For this purpose i will need a folder where all files are available which can be selected and downloaded. I will also create a single php page which contain the following scripts.

HTML

Create a simple PHP page and copy paste the below form.

jQuery

Add the following script in footer of web page. Don’t forget to add jQuery library before this script.
As you can see above that when you click on select all, all checkboxes are checked or unchecked. You can see my tutorial about how to select deselect all checkboxes using jquery.

PHP

Copy paste the below PHP script in the top of web page. When someone submit form first we are checking if files array is set or not, then we are creating zip file and downloading that file.
If you found this tutorial helpful so share it with your friends, developer groups and leave your comment.