【发布时间】:2015-08-29 13:14:07
【问题描述】:
我用 PHP 写了一个 zip 创建函数。它在 Ubuntu 上运行良好,但是当我在 Windows 机器上使用它时会引发错误。
<?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 系统上区分大小写。
-
目录存在,程序报未创建目标文件的错误