PHP Classes
Icontem

File: example1.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Joshua Townsend  >  Zip File  >  example1.php  
File: example1.php
Role: Example script
Content type: text/plain
Description: Example of using class to zip a file.
Class: Zip File
Create and extract ZIP archives in purely in PHP
 

Contents

Class file image Download
<?php
require "zip.class.php"// Get the zipfile class
$zipfile = new zipfile// Create an object
$zipfile->create_dir("."); // Add a subdirectory - must be done.  If a subdirectory is not wanted, just simply add one named "." as shown here
$zipfile->create_file(file_get_contents(__FILE__), "zip.txt"); // Add the data of the file that is wanted, and the full path to it in the zip.

// Allow user to download file
header("Content-type: application/zip");
header("Content-disposition: attachment;filename=\"zip.zip\"");
echo 
$zipfile->zipped_file();
?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products