PHP Classes

Zip File: Create and extract ZIP archives in purely in PHP

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 46%Total: 9,653 All time: 150 This week: 488Down
Version License PHP version Categories
zipfile 1.0GNU General Publi...4.0Files and Folders, Compression
Description 

Author

This class can be used to create and extract ZIP archives.

It can add and list files and directories in a ZIP archive.

The class uses pure PHP code, so it does not use the PHP ZIP extension.

Picture of Joshua Townsend
Name: Joshua Townsend <contact>
Classes: 3 packages by
Country: United States United States
Age: 33
All time rank: 21925 in United States United States
Week rank: 227 Down23 in United States United States Up

Recommendations

How to select files using file date and compress files as zip?
Select files by date and compress files as zip

ZipArchive not found exception, Class not found exception
ZipArchive how to resolve this

Convert the folder to ZIP
convert the folder to ".zip" format in php

Example

<?php
require "zip.class.php"; // Get the zipfile class
$zipfile = new zipfile; // Create an object
$zipfile->read_zip("myzip.zip"); // Read the zip file

// Now, $zipfile->files is an array containing information about the files
// Here is an example of it's use

foreach($zipfile->files as $filea)
{
    echo
"The contents of {$filea['name']}:\n{$file['data']}\n\n";
}
?>


  Files folder image Files (3)  
File Role Description
Accessible without login Plain text file example1.php Example Example of using class to zip a file.
Accessible without login Plain text file example2.php Example Example of using class to read a zip file
Plain text file zip.class.php Class The main zipfile class

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:9,653
This week:0
All time:150
This week:488Down
User Ratings User Comments (2)
 All time
Utility:66%StarStarStarStar
Consistency:69%StarStarStarStar
Documentation:-
Examples:61%StarStarStarStar
Tests:-
Videos:-
Overall:46%StarStarStar
Rank:3224