• 解决PHP文件(word/excel)下载 内容打开乱码问题


    编码转换不一定有用,一般可以解决文件名乱码问题

    iconv('utf-8','gb2312',$filename);

    具体代码如下:

       header("Pragma: public");
            header("Cache-control: max-age=".$expire);
            //header('Cache-Control: no-store, no-cache, must-revalidate');
            header("Expires: " . gmdate("D, d M Y H:i:s",time()+$expire) . "GMT");
            header("Last-Modified: " . gmdate("D, d M Y H:i:s",time()) . "GMT");
            header("Content-Disposition: attachment; filename=".$showname);
            header("Content-Length: ".$length);
            header("Content-type: ".$type);
            header('Content-Encoding: none');
            header("Content-Transfer-Encoding: binary" );
    //**********************************
            ob_clean();
        flush();
    //*********************************
            readfile($filename);

    注意上面的两行代码

    ob_clean();
    flush();

     参考:http://gaoke0820.blog.163.com/blog/static/216649652013152945362/?suggestedreading&wumii

  • 相关阅读:
    NodeJS、NPM安装配置步骤(windows版本)
    23种设计模式全解析
    js阻止浏览器默认事件
    js获取不同浏览器盒子宽度高度
    H5之重力感应篇
    JS中的call()和apply()方法
    html学习笔记
    less(css)语言快速入门
    power designer简单教程
    Strom开发配置手册
  • 原文地址:https://www.cnblogs.com/phpxuetang/p/4975280.html
Copyright © 2020-2023  润新知