简体   繁体   English

ZipArchive extractTo引发异常

[英]ZipArchive extractTo throwing exception

I'm using ZipArchive within a Code Igniter framework PHP Application. 我在Code Igniter框架PHP应用程序中使用ZipArchive It's working fine to extact however code igniter is throwing an error at the extractTo step but it doesn't crash the application and the application continues till the end but this error is still triggered and displayed by code igniter. 可以正常工作,但是代码点火器在extractTo步骤抛出错误,但是它不会使应用程序崩溃,并且应用程序继续运行到最后,但是该错误仍然由代码点火器触发并显示。 The directory exists before extractTo and it extracts properly and keeps going but why is this error thrown? 该目录在extractTo之前存在,并且可以正确提取并继续运行,但是为什么会引发此错误?

        $zipVar = new ZipArchive;
        $res = $zipVar->open($input_zip); 
        if ($res === TRUE) 
        {                           
             $zipVar->extractTo($target_dir);
             $zipVar->close();                        
         } 

在此处输入图片说明

Try 尝试

$input_zip = "" ; // 
$target_dir = "" ; //


if(!is_file($input_zip) || !is_readable($target_dir))
{
    die("Can't Read Input");
}

if(!is_dir($target_dir) || !is_writable($target_dir))
{
    die("Can't Write to Target");
}

$zip = new ZipArchive;
$res = $zip->open($input_zip);
if ($res === TRUE)
{
    echo 'ok';
    $zip->extractTo($target_dir);
    $zip->close();
}
else {
    die("Failed");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM