09
May
2007
xqus

PHP zip file class

I'm working on a Drupal module (can't say what) that needs to create a archive. I landed on ZIP, because it's the easiest to implement without requiring any external libs.
I searched around and found this, and with a few improvements I ended up with this: http://xqus.com/tools/class.zipfile.phps

The following changes were made:

  • Changed the name of the output method to save
  • Added some error checking in the save method
  • Made the save method return boolean
  • Added a check to see if the $files param to addFiles in an array
  • Changed the way the addFiles method reads file contents
  • Made the addFiles method return boolean
  • Made a output method to output the zipfile directly to the browser