previousFile_Archive (Previous) (Next) Dynamic generation of archive files for a gallerynext

View this page in Last updated: Sun, 18 Oct 2009
English | Brazilian Portuguese | Chinese | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Turkish

Examples

Examples – Some simple usage examples

Extract a tar archive to a sub directory

Here we simply take a tar archive called archive.tar and extract its contents to the folder

<?php
require_once "File/Archive.php";

File_Archive::extract('archive.tar/''output');
?>

Send a zip archive containing the content of a tar file to the standard output

<?php
require_once "File/Archive.php";

File_Archive::extract(
    
//The content of archive.tar appears in the root folder (default argument)
    
'archive.tar/',

    
//And is written to ...
    
File_Archive::toArchive(       // ... a zip archive
        
'archive.zip',             // called archive.zip
        
File_Archive::toOutput()   // that will be sent to the standard output
    
)
);
?>

Extracting a file from an archive

Use extract() to get files out of an archive. When specifying the file to extract, make sure to use the archive name as first folder.

<?php
require_once "File/Archive.php";

File_Archive::extract(
    
'archive.tar/inner.tgz/file.txt',
    
File_Archive::toOutput()
);
?>
previousFile_Archive (Previous) (Next) Dynamic generation of archive files for a gallerynext

Download Documentation Last updated: Sun, 18 Oct 2009
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
There are no user contributed notes for this page.