Search code examples
phphtmlphpdoc

.doc file generated with php doesn't show images when open with microsoft word app


this is my code to generate .doc

<?php
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment; Filename=SaveAsWordDoc.doc");
?>
<html>
<head>
<title>Saves as a Word Doc</title>
</head>
<body>
<h1>Header</h1>
<p>
some text.....
<br />
<img src="logo.jpg" border="0" alt="Logo" />
</p>
<p>
<ul>
<li>List 1</li>
<li>List 2</li>
</ul>
</p>
</body>
</html>

The problem is, when i open the generated .doc file, the image doesn't showed up.

Thanks in advance.


Solution

  • That is because the image is located somewhere else. It is basically foreign to your .doc. When you opened it. It was probably in a temp folder somewhere and couldn't locate "logo.jpg" image.