Backup a Folder To a Zip File With PHP

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

About The Author

    ADD YOUR COMMENT

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Receive fresh web design resources and SEO tips in your email by our weekly newsletter

You have Successfully Subscribed!