[英]How to check if file exist in zip archive
i have zip archive and after extract him i need to check if moduleConfig.xml exist inside zip archive. 我有zip存档,在解压缩后我需要检查zip存档中是否存在moduleConfig.xml。 How i can do that.
我怎么能这样做。
I try this 我试试这个
$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;
}
It should be like this: 它应该是这样的:
$zip = new ZipArchive();
if($zip->open('test.zip') === TRUE )
{
if ($zip->locateName('moduleConfig.xml') !== false)
{
echo "Config exists";
}
}
else {
echo 'Failed code:'. $res;
}
try: 尝试:
if ($zip->locateName('moduleConfig.xml') !== false)
{
echo "Config exists";
}
You can do this by using getFromName
您可以使用
getFromName
执行此getFromName
$zip = new ZipArchive();
if($zip->open('test.zip') === TRUE )
{
if($zip->getFromName('moduleConfig.xml') != false)
{
echo "Config exists";
// Do somthing
}
}
else {
echo 'Failed code:'. $res;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.