我正在尝试调试此脚本以在 localhost 上运行。return ,根据手册,这意味着“没有错误”,但仍然$zip->status
返回false。0
file_exists()
我手动检查,该文件实际上不存在。我在本地主机上运行 WAMP。
为什么会这样?我该如何解决?
这是我的确切代码:
$destination = "C:\wamp\www\temp\temp.zip";
$zip = new ZipArchive();
echo var_dump($zip);
echo "<br />";
$zzz = $zip->open($destination, ZipArchive::CREATE);
if($zzz === true) {
echo "created archive<br />";
}else{
//Var dump says it's true.. is that not a contradiction??
echo var_dump($zzz)."<br />Couldn't create zipArchive<br />";
}
//add the files
foreach($_SESSION['images'] as $file) {
$zip->addFile($file);
}
echo "Files ".$zip->numFiles."<br />Status ".$zip->status."<br />";
$zip->close();
if(!file_exists($destination)){
echo "destination doesnt exist";
}
这是该页面的输出..
object(ZipArchive)[1]
public 'status' => int 0
public 'statusSys' => int 0
public 'numFiles' => int 0
public 'filename' => string '' (length=0)
public 'comment' => string '' (length=0)
created archive
Files 16
Status 0
destination doesnt exist