PHP Classes

File: Example2.php

Recommend this page to a friend!
  Classes of Ijon Tichy   Zipek PHP ZipArchive Unzip and Zip files   Example2.php   Download  
File: Example2.php
Role: Example script
Content type: text/plain
Description: #this is example will create zip file from folder, file array and single file
Class: Zipek PHP ZipArchive Unzip and Zip files
Compress or decompress zip files using ZipArchive
Author: By
Last change:
Date: 4 years ago
Size: 1,131 bytes
 

Contents

Class file image Download
<?php #this is example will create zip file from folder, file array and single file

//-------------------------------------------------------------------------------
// Before you start please create some files and folders in example dir
//
// -.-(root)
// |
// |-[a]
// | |-file1.txt
// | |-file2.txt
// | |-[b]
// | |-file3.txt
// | |-[c]
// | |-file4.txt
// |-[d]
// |-file5.txt
// |-file6.txt
//
//-------------------------------------------------------------------------------

//-------------------------------------------------------------------------------
// Real code
//-------------------------------------------------------------------------------

require_once("Zipek.class.php");

$where2Save = 'tuZapisz';
$fName = 'letAllBeingsBeHappy.zip';

$zip = new Zipek($where2Save.'/'.$fName,true);
$zip->openfile(ZipArchive::CREATE);

$zip->addFolder('a');
$zip->addFilesFromArray(array('d/file5.txt',array('file'=>'d/file6.txt','folder'=>'dedede','rename'=>'file6.ddd')));
$zip->addFile('d/file5.txt','file7.txt');

$zip->showStatus();
$zip->make();