1
我使用此代码生成一个word文件并从浏览器下载它。这是工作在铬但不工作在Firefox中 文件是下载,但没有扩展名。在firefox中不生成word文件
$this->loadModel ('Template');
$template = $this->Template->findById ($template_id);
$doc_body = $template['Template']['content'] ;
header("Content-Type: application/vnd.msword");
header("Expires: 0");//no-cache
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");//no-cache
header("content-disposition: attachment;filename=".$template['Template']['title'].'-'.time().".doc");
echo "<html>";
echo "$doc_body";
echo "</html>";
die;
谢谢,工作:) –