20,384
社区成员
发帖
与我相关
我的任务
分享
include $abs_path.'/include/classes/class.zip.php';
$dir_array = explode(',', $_GET['namestr']);
for($i=0;$i<count($dir_array);$i++)
{
$dir_array[$i] = $abs_path.'/download/'.$dir_array[$i];
}
$filename = $abs_path.'/admin/backup/'.randompass(10).'_site_templates.zip';
$ziper = new zipfile();
$ziper->addFiles($dir_array);
$ziper->output($filename);
header("Cache-control: private");
header("Content-type: application/zip");
header("Content-transfer-encoding: binary\n");
header("Content-disposition: attachment; filename=\"".strtolower(str_replace(" ", "_", $settings[title]))."_templates.zip\"");
header("Content-Length: ".filesize($filename));
readfile($filename);
@unlink($filename);
exit;
//MS一个zip类
include $abs_path.'/include/classes/class.zip.php';
//获取get过来的文件名(多文件用,号隔开),将其转成数组
$dir_array = explode(',', $_GET['namestr']);
//遍历一下,构造文件真实路径
for($i=0;$i<count($dir_array);$i++)
{
$dir_array[$i] = $abs_path.'/download/'.$dir_array[$i];
}
//构造要生成的zip包
$filename = $abs_path.'/admin/backup/'.randompass(10).'_site_templates.zip';
//申明zip类
$ziper = new zipfile();
//添加实体文件
$ziper->addFiles($dir_array);
//输出到zip包里
$ziper->output($filename);
//读取zip包后,删除zip包
header("Cache-control: private");
header("Content-type: application/zip");
header("Content-transfer-encoding: binary\n");
header("Content-disposition: attachment; filename=\"".strtolower(str_replace(" ", "_", $settings[title]))."_templates.zip\"");
header("Content-Length: ".filesize($filename));
readfile($filename);
@unlink($filename);
exit;