PHP 增加了对 .ZIP 文件的读取功能

This module uses the functions of the ZZIPlib library by Guido Draheim to transparently read ZIP compressed archives and the files inside them.
这个模块使用 ZZIPlib 库(Guido Draheim)来读取 ZIP 压缩文档和里面的文件

Please note that ZZIPlib only provides a subset of functions provided in a full implementation of the ZIP compression algorithm and can only read ZIP file archives. A normal ZIP utility is needed to create the ZIP file archives read by this library.
请注意:这个库只是ZIP所有扩展功能的一个子集,只能读取 ZIP 文档里面的内容。一个普通的 ZIP 环境需要能创建 ZIP 文档

Zip support in PHP is not enabled by default. You will need to use the --with-zip configuration option when compiling PHP to enable zip support. This module requires ZZIPlib version >= 0.10.6.
PHP 没有默认支持 ZIP,你需要使用 --with-zip 配置编译你的 PHP.这个模块需要 ZZPIlib 版本>=0.10.6

Note: Zip support before PHP 4.0.7 is experimental. This section reflects the Zip extension as it exists in PHP 4.0.7 and later.
注意:zip在 4.0.7之前是测试的。这一章写的是 php4.0.7 和以后版本的东西

Example Usage
This example opens a ZIP file archive, reads each file in the archive and prints out its contents. The test2.php archive used in this example is one of the test archives in the ZZIPlib source distribution.

Example 1. Zip Usage Example

<?php

$zip = zip_open("/tmp/test2.zip");

if ($zip) {

while ($zip_entry = zip_read($zip)) {
echo "Name: " . zip_entry_name($zip_entry) . " ";
echo "Actual Filesize: " . zip_entry_filesize($zip_entry) . " ";
echo "Compressed Size: " . zip_entry_compressedsize($zip_entry) . " ";
echo "Compression Method: " . zip_entry_compressionmethod($zip_entry) . " ";

if (zip_entry_open($zip, $zip_entry, "r")) {
echo "File Contents: ";
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
echo "$buf ";

zip_entry_close($zip_entry);
}
echo " ";

}

zip_close($zip);

}

?>

时间: 2024-09-12 02:20:11

PHP 增加了对 .ZIP 文件的读取功能的相关文章

PHP 增加了对 .ZIP 文件的读取功能_php基础

This module uses the functions of the ZZIPlib library by Guido Draheim to transparently read ZIP compressed archives and the files inside them. 这个模块使用 ZZIPlib 库(Guido Draheim)来读取 ZIP 压缩文档和里面的文件 Please note that ZZIPlib only provides a subset of funct

PHP读取zip文件的方法示例_php技巧

本文实例讲述了PHP读取zip文件的方法.分享给大家供大家参考,具体如下: <?php $zip = zip_open("111.zip"); if ($zip) { while ($zip_entry = zip_read($zip)) { echo "Name: " . zip_entry_name($zip_entry) . "n"; echo "Actual Filesize: " . zip_entry_fil

Java从zip文件中解析XML数据实例

从zip文件中解析xml文件一般步骤是先解压zip文件,然后在解析xml,这里直接从zip文件中读取xml的输入流进行解析,减少I/O操作.下面是一个从zip文件中解析xml文件的示例:    代码如下 复制代码 /**  * 从zip文件中解析XML数据<br/>  * @param filePath 文件绝对路径  * @return List<?>  * @throws IOException  * @throws DocumentException  * @author 大

Android Zip文件解压缩代码

 在Android平台中如何实现Zip文件的解压缩功能呢? 因为Android内部已经集成了zlib库,对于英文和非密码的Zip文件解压缩还是比较简单的,下面Android123给大家一个解压缩zip的java代码,可以在Android上任何版本中使用,Unzip这个静态方法比较简单,参数一为源zip文件的完整路径,参数二为解压缩后存放的文件夹.private static void Unzip(String zipFile, String targetDir) {   int BUFFER =

php读取zip文件(删除文件,提取文件,增加文件)实例

从zip压缩文件中提取文件  代码如下 复制代码 <?php /* php 从zip压缩文件中提取文件 */ $zip = new ZipArchive;   if ($zip->open('jQuery五屏上下滚动焦点图代码.zip') === TRUE) {//中文文件名要使用ANSI编码的文件格式     $zip->extractTo('foldername');//提取全部文件     //$zip->extractTo('/my/destination/dir/', a

php操作(删除,提取,增加)zip文件方法详解

 本文给大家分享的是php操作zip文件的方法示例,包括了从zip压缩文件中提取文件.从一个zip压缩文件中删除文件.添加一个文件到zip压缩文件中,推荐给大家,有需要的小伙伴参考下.     php读取zip文件(删除文件,提取文件,增加文件)实例 从zip压缩文件中提取文件   代码如下: <?php /* php 从zip压缩文件中提取文件 */ $zip = new ZipArchive; if ($zip->open('jQuery五屏上下滚动焦点图代码.zip') === TRUE

php操作(删除,提取,增加)zip文件方法详解_php技巧

php读取zip文件(删除文件,提取文件,增加文件)实例 从zip压缩文件中提取文件 复制代码 代码如下: <?php /* php 从zip压缩文件中提取文件 */ $zip = new ZipArchive; if ($zip->open('jQuery五屏上下滚动焦点图代码.zip') === TRUE) {//中文文件名要使用ANSI编码的文件格式     $zip->extractTo('foldername');//提取全部文件     //$zip->extractT

java.util.zip创建和读取zip文件的类

写了一个用java.util.zip创建和读取zip文件的类 跟大家分享一下 里面用了递归调用 呵呵 近期用了不少递归调用!有空总结一下! /** TestZip.java coding by Serol Luo. rollingpig@163.com 2003/07/03 http://www.chinaunix.net/forum/viewforum.php?f=26 转载请保留此信息 */ import java.util.*; import java.util.zip.*; import

sftp下载zip文件-java从sftp上下载到本地磁盘的zip文件读取不了,请大家帮忙解答下,谢谢!

问题描述 java从sftp上下载到本地磁盘的zip文件读取不了,请大家帮忙解答下,谢谢! 从sftp上下载到本地的zip文件是没问题的,用压缩工具打开能查看里面的文件,为什么就是读取不了呢? java从sftp下载zip文件到本地磁盘代码: import java.io.InputStream; import java.util.Date; import com.ibm.gbs.ai.portal.framework.util.DateUtils; import com.jcraft.jsch