- //1. 打开zip文件
- $myzip = zip_open("tezt.zip");
- if (!is_resource($myzip)) {
- die("打开zip文件失败:$zipfile");
- }
- //2. 读取zip存档项
- while($zipEntry = zip_read($myzip)) {
- $resource = zip_entry_open($myzip, $zipEntry, "rb");
- $fileName = zip_entry_name($zipEntry);
- if ($resource == true) {
- // 读取zip存档项的内容
- $fileContent = zip_entry_read($zipEntry);
- echo("File: " . $fileName . " successfully opened.\n");
- echo("File content: " . $fileContent)."\n";
- // 关闭zip归档项
- zip_entry_close($zipEntry);
- } else {
- echo("Failed to Open.");
- }
- }
- //3. 关闭zip文件
- zip_close($myzip);
复制代码
|