$filename= date("YmdHis");
$zip = new ZipArchive();//使用本类,linux需开启zlib,windows需取消php_zip.dll前的注释
$zip->open($filename.".zip", ZipArchive::OVERWRITE); //$data 就是从数据库里面读出的数字
foreach( $data as $val){
$attachfile = "E:\bysj\bysj".$val['fileaddr'].$val['filename']; //写硬路径,但建议用PHP环境变量
$attachfile=iconv("UTF-8","GBK",$attachfile); //转码,是打包中文文档的关键
$zip->addFile( $attachfile , basename($attachfile)); //压栈
}
$zip->close();//关闭
header("Content-type:text/html;charset=utf-8");//设置页面编号
header("Cache-Control: public");
header("Content-Description: File Transfer");
header('Content-disposition: attachment; filename='.basename($filename)); //文件名
header("Content-Type: application/zip"); //zip格式的
header("Content-Transfer-Encoding: binary"); //告诉浏览器,这是二进制文件
header('Content-Length: '. filesize($filename)); //告诉浏览器,文件大小
@readfile($filename.".zip");
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有