如何在 Windows 上使用 php 解压文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/541573/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:57:35 来源:igfitidea点击:
how to unrar files using php on windows
提问by Paolo Bergantino
how to unrar files using php on windows? Is there any script or codes to make it possible?
如何在 Windows 上使用 php 解压文件?是否有任何脚本或代码使其成为可能?
Thanks
谢谢
回答by Paolo Bergantino
Check this link out:
看看这个链接:
http://us2.php.net/manual/en/book.rar.php
http://us2.php.net/manual/en/book.rar.php
Using that extension, you can do something like this:
使用该扩展,您可以执行以下操作:
$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);