php header 下载文件兼容IE文件名乱码问题

//导出word开始
        $doc_name = $result['company_info']['ENTNAME']."信用舆情报告.doc";
        ob_start(); //打开缓冲区  
        header("Cache-Control: public");  
        Header("Content-type: application/octet-stream");  
        Header("Accept-Ranges: bytes");  
        if (strpos($_SERVER["HTTP_USER_AGENT"],'MSIE')) {

            $doc_name = iconv("utf-8","gb2312",$doc_name);
        header('Content-Disposition: attachment; filename='.$doc_name);  
        }else if (strpos($_SERVER["HTTP_USER_AGENT"],'Firefox')) {  
        Header('Content-Disposition: attachment; filename='.$doc_name);  
        } else {  
        header('Content-Disposition: attachment; filename='.$doc_name);  
        }  
        header("Pragma:no-cache");  
        header("Expires:0");  
        ob_end_flush();//输出全部内容到浏览器

 

posted @ 2018-08-08 17:30  猖狂的小山猪  阅读(459)  评论(0编辑  收藏  举报