[英]PHP: how to retrieve the filename of the file contained in .gz?
我的 test.gz 包含例如:image1.jpg。
如何解壓縮 test.gz 以便它給我 image1.jpg ?
我試過這種方法:
$file = gzopen($file_name, 'rb');
$out_file = fopen($out_file_name, 'wb');
但它假設您需要知道 .gz 文件中包含的文件名
問候
您需要使用 PHP PharData來提取和讀取其內容。
提取tar
或tar.gz
:
$phar = new PharData('myphar.tar');
$phar->extractTo('/full/path');
要列出所有文件,您可以使用:
archive = new PharData('/upload/directory/myphar.tar.gz');
foreach (new RecursiveIteratorIterator($archive) as $file) {
echo $file . "<br />";
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.