PHP如何打开.doc和.docx文件?

时间:2015-12-27 10:08:42

标签: php

doc files

$filename = 'ahfdghasfdh.doc';
header('Content-type: application/msword');
header('Content-Disposition: inline; filename="testqq"');
@readfile($filename); 

我试过这段代码不能正常工作。如何使用php在浏览器上打开.doc文件。

2 个答案:

答案 0 :(得分:0)

尝试以下代码。

<?php
$filename = 'ahfdghasfdh.doc';
header('Content-disposition: inline');
header('Content-type: application/msword'); // not sure if this is the correct MIME type
readfile($filename);
exit;
?>

答案 1 :(得分:0)

您可以这样打开:

<a href="yourfile.doc">MSWORD FILE</a>

其他解决方案@vinod已经分享了

如果你只是想在浏览器上打开doc文件而不是我推荐使用 GOOGLE DOCS。

相关问题