使用docx而不是doc强制下载php问题

使用docx而不是doc强制下载php问题,php,header,mime-types,attachment,doc,Php,Header,Mime Types,Attachment,Doc,我用的是典型的 if($ext == "doc" && file_exists($file)) { header("Content-disposition: attachment; filename= '$filename'"); header('Content-type: application/msword'); readfile($file); } 这个文件很好用。但是,当我使用: if($ext == "doc" &

我用的是典型的

if($ext == "doc" && file_exists($file)) {
    header("Content-disposition: attachment; filename= '$filename'");
    header('Content-type: application/msword');
    readfile($file);
           }
这个文件很好用。但是,当我使用:

if($ext == "doc" && file_exists($file)) {
    header("Content-disposition: attachment; filename= '$filename'");
    header('Content-type: application/vnd.openxmlformats officedocument.wordprocessingml.document');
    readfile($file);

    }
当我在word中打开下载的文档时,该文档显示错误,表明它已损坏。但是,如果我单击“前进”,它将正常打开


如何避免出现此损坏的文件错误。

可能会有所帮助。对于不知道您的系统是什么样的人来说,“单击前进”意味着什么?@Marc B。很抱歉,我键入了这么糟糕的内容。现在应该更清楚了。我只是想在word中单击“前进”。