我已经看到了PHP中的ZipArchive类,它可以让你阅读zip文件。但我想知道是否有一种方法来迭代虽然它的内容没有提取文件第一个在PHP中,可以先检查Zip文件的内容而不先提取其内容?
20
A
回答
39
由于发现的评论:
下面的代码可以用来获得 一个zip文件,所有文件名的列表。
<?php $za = new ZipArchive(); $za->open('theZip.zip'); for($i = 0; $i < $za->numFiles; $i++){ $stat = $za->statIndex($i); print_r(basename($stat['name']) . PHP_EOL); } ?>
-3
重复的问题。发帖前搜索。 PHP library that can list contents of zip/rar files
<?php
$rar_file = rar_open('example.rar') or die("Can't open Rar archive");
$entries = rar_list($rar_file);
foreach ($entries as $entry) {
echo 'Filename: ' . $entry->getName() . "\n";
echo 'Packed size: ' . $entry->getPackedSize() . "\n";
echo 'Unpacked size: ' . $entry->getUnpackedSize() . "\n";
$entry->extract('/dir/extract/to/');
}
rar_close($rar_file);
?>
14
http://www.php.net/manual/en/function.zip-entry-read.php
<?php
$zip = zip_open("test.zip");
if ($zip)
{
while ($zip_entry = zip_read($zip))
{
echo "<p>";
echo "Name: " . zip_entry_name($zip_entry) . "<br />";
if (zip_entry_open($zip, $zip_entry))
{
echo "File Contents:<br/>";
$contents = zip_entry_read($zip_entry);
echo "$contents<br />";
zip_entry_close($zip_entry);
}
echo "</p>";
}
zip_close($zip);
}
?>
的
相关问题
- 1. 内部zip文件内容
- 2. 内部zip文件内容
- 3. PHP库,可以列出zip/rar文件的内容
- 4. PHP - 读取zip文件的内容而不保存在服务器上
- 5. 检查内容可编辑内容
- 6. 提取内容.img文件
- 7. 如何使用VB从Zip文件中提取所有内容?
- 8. Beautifulsoup =提取内容中的内容
- 9. 文件获取内容PHP
- 10. PHP获取文件内容
- 11. 根据内容优先考虑文本
- 12. Node中是否可以在文件中读取其内容(不导出异步)的内容?
- 13. 在php中获取文件内容
- 14. 提取符号链接zip文件的内容与symlink同名
- 15. SharpZipLib检查并选择一个ZIP文件的内容
- 16. 从文本文件中提取内容
- 17. 如何在.NET 4.5中将zip文件内容提取到文件夹中
- 18. 从文件中获取信息而不遍历其内容
- 19. 检查.class文件中的内容
- 20. 读zip文件的内容而无需提取的什么,我想实现
- 21. “最终折叠内容”中的“%”如何计算 - 优先显示可见内容
- 22. 我可以从外部文件中提取html内容吗?
- 23. 从Zip文件中的文件读取内容
- 24. 提取zip文件内容并动态重命名目录
- 25. 使用php提取xml文件集中的内容使用php
- 26. 我可以使用Ant提取iso文件的内容吗?
- 27. 提取内容属性的内容?
- 28. 文件夹Java的Zip内容
- 29. Powershell - 验证zip文件的内容
- 30. opengl - 与framebuffer的先前内容混合
可能重复[PHP库,可以列出ZIP/RAR文件的内容(http://stackoverflow.com/questions/1524186/php-library-that -can-list-contents-of-zip-rar-files) – 2012-03-22 06:42:44