我在PHP中編寫了一個zip創建函數。它在Ubuntu上正常工作,但當我在Windows機器上使用它時會引發錯誤。php zip創建函數不能在窗口上工作
<?php
$Zip = new ZipArchive();
$filelocation = 'update';
$Ziplocation = 'ZipVila/ZipEx.zip';
$Zipfolder = 'ZipVila';
$Zip->open($Ziplocation, ZipArchive::CREATE | ZipArchive::OVERWRITE);
$files = scandir($filelocation);
print_r($files);
unset($file[0], $file[1]); // Windows throws an "object file is not defined" error in this line
foreach ($files as $file) {
$Zip->addfile($filelocation."/{$file}", $file);
echo "File Added";
}
$Zip->close();
echo "Zip Closed";
?>
任何人都可以幫助我嗎?
什麼是錯誤它顯示? ZipVila目錄是否存在?目錄名稱在非Windows系統上區分大小寫。 –
目錄存在,並且程序給出了目標文件未被創建的錯誤 –