if($attach and $attachTemp){
move_uploaded_file($attachTemp,'static/downloads/'.$lastIdInsert."_".$attach);
$dataAttach['attach'] = $lastIdInsert."_".$attach;
$updateAttach = $this->model_schemas->update($lastIdInsert,$data=array('download'=>'1'));
/*ZIP IT*/
$zip = new ZipArchive();
$zip->open('static/downloads/'.$lastIdInsert."_".$attach);
$zip->addFile('static/downloads/'.$lastIdInsert."_".$attach,$lastIdInsert.".zip");
$zip->close();
}
它不会压缩该目录中的文件。
然后我收到2个错误:
Message: ZipArchive::addFile() [ziparchive.addfile]: Invalid or unitialized Zip object
Message: ZipArchive::close() [ziparchive.close]: Invalid or unitialized Zip object
文件已移动但未压缩。
答案 0 :(得分:2)
您必须将标志指定为create或overwrite。你可以这样做;
$zip->open('static/downloads/'.$lastIdInsert."_".$attach,
ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);