Zip文件numFiles
似乎返回比實際包含在存檔1個額外的文件。例如,如果存檔文件只有99個文件,則numFiles
將表示100個文件。在以下代碼中,filesProcessed
始終是文件實際數量的+1(它已初始化爲0)。這是一個已知的錯誤,還是歸檔(zip文件)作爲文件的歸檔?ZipArchive numfiles不準確
public function zipExtract($file, $extractPath)
{
if ($this->zip->open($file) === true) {
$this->filesProcessed = $this->zip->numFiles;
$this->zip->extractTo($extractPath);
$this->zip->close();
} else {
throw new Exception(__FUNCTION__ . " could not extract file. Failed to open: {$file}.");
}
}
難道是隱藏文件? –
我不能確認,但在3個文件test.zip它正確計數三。所以即時猜測文件結構中的某個地方必須有一個隱藏的文件導致它。 – Alex