php利用header函数生成word,内容有,但是就是没有图片,求解。有没有好的php类可以生成word,除了phpword

function makeWord($content){

$filename = date('YmdHis');
extract($content);
foreach ($pic as $key => $value) {
    if($value){ 
        $key = '123<img src="https://172.16.59.56:28443/app/helpers/tcpdf/examples/images/{$key}.png">';
}
header('pragma:public'); 
header('Content-type:application/vnd.ms-word;charset=utf-8;name="'.$filename.'".doc');
header("Content-Disposition:attachment;filename=$filename.doc"); 
$html = '<html 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=UTF-8"/>';
echo $html.$key.'</html>';
}

}
是我图片地址不对么,但是我的链接地址是可以打开的,我测试了。word里面只有123,图片显示错误

阅读 2.4k
2 个回答

你查看下载后的文件源代码, 看内容.

<html 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=UTF-8"/>
<body>
<h1>Hello</h1>
<img src="https://tpc.googlesyndication.com/daca_images/simgad/15931051307157817356?w=400&h=209">
</html>

我这可以. 那不知道问题在哪了.

clipboard.png

推荐问题
宣传栏