Backup a Folder To a Zip File With PHP

Unzip ZIp php Best WordPress Hosting

Many times we need to create a backup utility in our web application. Creating a zip of folder before taking backup is nice idea to reduce size of backup file. You may have seen so many hosting websites and file hosting websites which allow users to compress files as zip file and then download. For making this kind of features, you must add a function of selecting files and then adding it to a zip file.

With the PHP its easy to create a zip of a folder. For this, we can simply use “pclzip.lib.php“. This is a php class library. PclZip gives you the ability to manipulate zip formatted archives. You can create an archive, list the content and extract all its content in the file system.

Download this library from the website and include in your code.  See the code snippet below

I am sure this will solve your problem. If you have any problem in implementing this code you can ask your problems via comment. If you like this post, share it with your friends and subscribe Webtips for daily email updates.

advertisement

1 Comment

  1. Thanks for ones marvelous posting! I seriously enjoyed reading it,
    you can be a great author. I will make sure to bookmark your blog and will often come back
    later on. I want to encourage you to continue your great writing,
    have a nice holiday weekend!

Leave a Reply

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