Firefox 不生成word文件

word file not generating in firefox

我正在使用此代码生成一个 word 文件并从浏览器下载它。这在 chrome 中有效,但在 firefox 中无效 文件已下载但没有扩展名。

    $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; 

请尝试将此作为代码的一部分。

$filename = $template['Template']['title'].'-'.time().".doc";
header("content-disposition: attachment;filename=\"$filename\"");