Code Monkey home page Code Monkey logo

zip-php's Introduction

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.

zip-php's People

Contributors

banksy89 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

indian2020

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.