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
我不知道它是怎么发生的,但是,重新启动服务器后所有错误都消失了。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.