Convert html with image to ms.word
- by user1629258
I have the html code as below:
file.html
<body>
<h1>TEST</h1>
<p>this is test</p>
<table>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td><img src="../../../wamp/www/html2doc/SGEPP.jpg"></td>
</tr>
</table>
html2doc.php
<?php
$handle = fopen("doc2html.html","r");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=html2word.doc");
echo $contents;
?>
The problems:
when I convert it,I get html2word.doc but I can get only all texts from html file.For the images in html file I can not get it, it is missing images.So I want to get all data from html and images also.How do I fix this?Anyone help me please,Thanks.