PHP Classes

PHP Directory Compress Recursive: Create ZIP file with all the files of a directory

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
Not yet rated by the usersTotal: 168 All time: 8,878 This week: 206Up
Version License PHP version Categories
dircompress 1.0.0Freeware5PHP 5, Files and Folders, Compression
Description 

Author

This class can create ZIP file with all the files of a directory.

It can traverse a directory recursively to extract the list of files.

The class generates a ZIP archive by packing and compressing the list of files contained in the hierarchy of directories and sub-directories of the initial directory.

Picture of José Quijado
  Performance   Level  

 

Example

<?php
   
/**
     * The name of the source and destination folders must be specified relative to
     * the script wich includes this one.
     */

    /**
     * We create a DirCompress class object with the right source and destination directories.
     */
   
$objeto = new DirCompress("origen/", "destino/");
   
/**
     * We establish the name of the compressed zip file, which is mandatory.
     * If we don't include a .zip name extension, this will be added by the class,
     * so this is optional. It will be .zip named anyway.
     */
   
$objeto->setZipFileName("comprimido.zip");
   
/**
     * We create the zip compressed file.
     */
   
$objeto->createZip();

    echo
$objeto->makeLink("Descargar");
?>


Details

DirCompress

Clase para comprimir todo un directorio, con toda su jerarquía, en un zip.

Esta clase permite comprimir todo un directorio en un zip, manteniendo toda la jerarquía de subdirectorios, y colocando todos los archivos en sus correspondientes rutas.

Puedes leer más sobre ella en https://eldesvandejose.com.


  Files folder image Files (33)  
File Role Description
Files folder imageejecucion (1 file)
Files folder imageorigen (4 directories)
Files folder imagevendor (1 directory)
Accessible without login Plain text file autoload.php Aux. Auxiliary script
Accessible without login Plain text file index.php Aux. Auxiliary script
Accessible without login Plain text file README.md Doc. Documentation

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  
 100%
Total:168
This week:0
All time:8,878
This week:206Up