Skip to content

banksy89/ZIP-PHP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Compress a Directory into a ZIP using PHP

zip.php holds the zipping function. To use:

$result = zipper ( $_SERVER['DOCUMENT_ROOT'] . '/your/file/path', array ( 'ignore.html' ), 'Zipper.zip', TRUE );


So to use there is just one line to call with a few parameters. In this order:

  1. Path to the directory - I have put the document root there, just need to assign the exact location of the Directory you want to compress
  2. Ignore Array - put any files you wish to be ignored and not compressed.
  3. The Archive name - call this whatever you want and end it in .zip
  4. Overwrite - Set this to TRUE or FALSE depending if you want to overwrite an existing archive or not.

I provided a /Test directory with some files, which is to demonstrate a folder location - within zip.php there is an example of the function call. Download this exactly, and it should work!

So that's it, you can choose to ignore specific files and just provide a directory to with files in the compress. Quite simple to extend this way and add functionality, but this is the simplest of forms to actually create the ZIP file.

The function returns a BOOLEAN so you can do a condition depending on the call back TRUE/FALSE.

About

A simple script to compress a directory into a zip

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages