[英]HTML to doc using php default save as web document (.html) issue
我已經使用php和header創建了HTML到Doc。 它會創建我想要的適當的doc文件,但是當我下載該doc文件並單擊“另存為”時,其默認類型為webpage(.html)。
這是我用來創建doc文件的代碼。
header('Content-Description: File Transfer');
header("Content-type: application/msword;charset=iso-8859-8");
header('Content-Disposition: attachment;filename=IEP-Annual-Goals.doc');
header("Pragma: no-cache");
header("Expires: 0");
$html='<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-8" />
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 9">
<meta name=Originator content="Microsoft Word 9">
<xml>
<w:WordDocument>
<w:View>Print</w:View>
<w:Zoom>90</w:Zoom>
<w:Save>.doc</w:Save>
<w:DoNotOptimizeForBrowser/>
</w:WordDocument>
</xml>';
// and main html block
//Then simply echo html to directly download doc file.
echo $html;
當我打開doc文件並另存為時,其默認類型為web document(.html),但我需要將其作為document(.doc)文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.