如何检查文件是否存在于 zip 存档中 [英] How to check if file exist in zip archive
本文介绍了如何检查文件是否存在于 zip 存档中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有 zip 存档,解压后我需要检查 zip 存档中是否存在 moduleConfig.xml.我该怎么做.
i have zip archive and after extract him i need to check if moduleConfig.xml exist inside zip archive. How i can do that.
我试试这个
$zip = new ZipArchive();
if($zip->open('test.zip') === TRUE )
{
if(file_exists($zip->getFromName('moduleConfig.xml')))
{
echo "Config exists";
// Do somthing
}
}
else {
echo 'Failed code:'. $res;
}
推荐答案
应该是这样的:
$zip = new ZipArchive();
if($zip->open('test.zip') === TRUE )
{
if ($zip->locateName('moduleConfig.xml') !== false)
{
echo "Config exists";
}
}
else {
echo 'Failed code:'. $res;
}
这篇关于如何检查文件是否存在于 zip 存档中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文