extension=php_zip.dll注释掉

<?php
$filename = "test.zip";
ob_end_clean();
$zip = new ZipArchive();
$zip->open($filename, ZipArchive::OVERWRITE);
$func=dirname(__FILE__)."/test/";

$attachfile = $func."test.txt";//写绝对径,建议用PHP环境变量
// $attachfile=iconv("UTF-8","GBK",$attachfile); //转码,打包中文文档
$zip->addFile( $attachfile , basename($attachfile)); //把文件放入zip
$zip->addFile( $attachfile , basename( $func."test1.txt"));

$zip->close();//关闭
header('Content-Description: File Transfer');
Header("content-type:application/x-zip-compressed");
header('Content-Disposition: attachment; filename='.basename($filename));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($filename));
ob_clean(); //清空但不关闭输出缓存
flush();
@readfile($filename);
@unlink($filename);//删除打包的临时zip文件。文件会在用户下载完成后被删除

最新文章

  1. 前端构建工具之gulp(一)「图片压缩」
  2. MySql的一些用法
  3. UIWindow &amp; UIWindowLevel
  4. 在javascript中如何取消事件冒泡
  5. rc522 ,pn544区别
  6. POJ 1659 Frogs&#39; Neighborhood
  7. (五)solr7.1.0之solrJ的使用
  8. RobotFramework下的http接口自动化Set Request Header 关键字的使用
  9. Django(博客系统):文章内容使用django-ckeditor、文章简介使用django-tinymce
  10. python的join(string)函数
  11. React文档(二十二)context
  12. 关于always块内for循环的执行方式
  13. stl string的erase方法
  14. Python学习之路基础篇--02Python基础+小作业
  15. &quot;美女相册&quot;的 js 实现代码
  16. Web Services的学习一
  17. JAVA 线程池入门事例
  18. 关于RSA加密算法的工具类
  19. Simple2D-17(音乐播放器)嵌入 ImGui 库
  20. u3d change terrain textrue&amp;height

热门文章

  1. 关于Membership和身份认证的记录
  2. easyui combobox的增加全选解决方案
  3. 怎么不让别人ping服务器
  4. 【sqli-labs】 less8 GET - Blind - Boolian Based - Single Quotes (基于布尔的单引号GET盲注)
  5. Type class-Typeclass-泛型基础上的二次抽象---随意多态
  6. 微信小程序中的iPhone X适配问题
  7. 浏览器内置的base64方法
  8. Spark中Task,Partition,RDD、节点数、Executor数、core数目的关系和Application,Driver,Job,Task,Stage理解
  9. select和epoll最大的区别
  10. Idea中修改servlet模板