<?php
/**
* Project: PHPUnzip: A PHP class to read and extract zip archives in a stream based manner<br />
* File: example.php<br />
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.<br />
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.<br />
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA<br />
*
* @author drew010 <drew@drew-phillips.com>
* @version 1.0 (June 21 2007)
* @package PHPUnzip
*
*/
require_once 'PHPUnzip.class.php';
$read_to_file = false;
$open = $zip->Open('testfile.zip');
if (!$open) die("Failed to open file.");
if ($read_to_file) {
$zip->SetOption(ZIPOPT_FILE_OUTPUT, true); // save data to files, instead reading to memory
$zip->SetOption(ZIPOPT_OUTPUT_PATH, '/tmp/'); // where to save the files, include trailing /
}
$success = $zip->Read();
if (!$success) {
echo "Error {$zip->error} encountered: {$zip->error_str}.<br /><br />";
}
if (sizeof($zip->files) >
0) {
foreach($zip->files as $file) {
echo "Error {$file->error} while extracting \"$file->name\"<br /><br />";
} else {
echo "Filename: <b>{$file->path}/{$file->name}</b>,
Size: <b>{$file->size}</b>,
Compressed Size: <b>{$file->compressed_size} ({$file->compression_ratio}%)</b><br />";
echo
"<textarea style='width: 500px; height: 200px'>" .
htmlspecialchars($file->data) .
"</textarea><br /><br />";
}
}
}
?>