强制浏览器下载PDF文件

        if(empty($filename))
        {
            return FALSE;
        }       
        
        // http headers
        header('Content-Type: application-x/force-download');
        header('Content-Disposition: attachment; filename="' . basename($filename) .'"');
        header('Content-length: ' . filesize($filename));

        // for IE6
        if (false === strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6')) {
            header('Cache-Control: no-cache, must-revalidate');
        }
        header('Pragma: no-cache');
            
        // read file content and output
        return readfile($filename); 

 

posted @ 2013-11-14 13:25  WhoAmMe  阅读(921)  评论(0编辑  收藏  举报