PHP – Read files/content/file details from a .zip archive, without extracting them



















$zip = zip_open("D:tests".$outFile);
if ($zip) {
while ($zip_entry = zip_read($zip)) {
echo "Name:               " . zip_entry_name($zip_entry) . "n";
echo "Actual Filesize:    " . zip_entry_filesize($zip_entry) . "n";
echo "Compressed Size:    " . zip_entry_compressedsize($zip_entry) . "n";
echo "Compression Method: " . zip_entry_compressionmethod($zip_entry) . "n";
if (zip_entry_open($zip, $zip_entry, "r")) {
echo "File Contents:n";
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
echo "$bufn";
zip_entry_close($zip_entry);
}
echo "n";
}
zip_close($zip);
}

The above code, gives an example of the methods to use for extracting the contents of files, or status and size of files, in a .zip archive.

Leave a Reply

Your email address will not be published. Required fields are marked *

*