please help me, i tried to create zip file using ZipArchive in PHP but allways get Emty Zip file,
this is my code
> $files = array('/upload/download1.jpg','/upload/download2.jpg');
$dir=dirname($_SERVER["SCRIPT_FILENAME"]);
$zipname = 'testme123.zip';
$zip = new ZipArchive;
$zip->open($zipname, ZipArchive::CREATE);
foreach ($files as $file) {
$filename=$dir.$file;
if(is_readable($filename))
{
$zip->addFile('C:\inetpub\wwwroot\wss\VirtualDirectories\80\downloadzip/upload/download1.jpg');
}else{echo($filename . 'error');}
}
$zip->close();
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename='.$zipname);
header('Content-Length: ' . filesize($zipname));
readfile($zipname);
?>
i try everything i know with addFile :
but still not working i really don't know what i miss with this code
bytheway my php version 5.3.28 running on IIS win server 2008
答案 0 :(得分:0)
我不知道它是如何发生的,但是,重新启动服务器后所有错误都消失了...... LOL