我正在尝试将php文件导出为word文档,然后我使用了Google搜索并找到了:
header('Content-type: application/vnd.ms-word');
header("Content-Disposition: inline; filename=$filename.doc");
header("Content-Disposition: attachment; filename=$filename.doc");
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header('Pragma: anytextexeptno-cache', true);
header('Cache-control: private');
header('Expires: 0');
但这只适用于Windows。在OSX中它表示无效的文件类型,并且在Linux中它尝试在Chrome中打开,然后失败。
谁能告诉我我失踪了什么?我希望计算机相信它是单词,如果是,那么文档是有效的(我知道因为Windows工作)。看起来我需要做一些事情告诉Unix系统它是一个word文档,即使它真的是一个HTML文档。
OH和我在那里看到了几个库,但我避免这样做,因为我想在飞行中创建它们,而且它们不需要花哨。谢谢!
答案 0 :(得分:0)
将内容类型标题作为application / msword传递通常对我有用。