时间:2021-07-01 10:21:17 帮助过:2人阅读
function zip_file(string $filename){
if(!is_file($filename)){
return false;
}
$zip=new ZipArchive();
$zipName=basename($filename).'.zip';
//打开指定压缩包,不存在则创建,存在则覆盖
if($zip->open($zipName,ZipArchive::CREATE|ZipArchive::OVERWRITE)){
//将文件添加到压缩包中
if($zip->addFile($filename)){
@unlink($filename);
}
$zip->close();
return true;
}else{
return false;
}
}相关推荐:
php实现解压功能的函数
以上就是php单文件压缩的功能函数的实现的详细内容,更多请关注Gxl网其它相关文章!