Skip to main content Help Control Panel

Aubagne HipHop

Tout le Hip Hop d'Aubagne et des alentours

Home «   Server software «  

Documentation: shared/zipfile.php

class zipfile - Create a zip archive file

This script is useful to package several files on the fly into a single downloaded archive.

Example:
// build a zip archive
    
include_once 'zipfile.php';
    
$zipfile = new zipfile();

    
// place all files into a single directory
    
$zipfile->store('files/'time());

    
// archive each file
    
foreach($items as $id => $name) {

        
// read file content
        
if($content Safe::file_get_contents($file_path.$name)) {

            
// add the binary data stored in the string 'filedata'
            
$zipfile->store('files/'.$nameSafe::filemtime($file_path.$name), $content);
        }
    }

    
// suggest a download
    
Safe::header('Content-Type: application/zip');
    
Safe::header('Content-Disposition: attachment; filename="download.zip"');

    
// send the archive content
    
echo $zipfile->get();
    return;


This script is a reference file of this system.

Voir aussi:

Licence: GNU Lesser General Public License

Auteurs:

shared/zipfile.php - Compressed data

shared/zipfile.php - File descriptors

shared/zipfile.php - Number of entries

deflate() - Deflate one file

function deflate($name, $date, $data=NULL)

store() - Store one file without compressing it

function store($name, $date, $data=NULL)

get() - Dump the archive content

function get()

Tools
Browse the source of this script
Server software