title: Easiest way to insert image into docx file using PHP
body: <p>I am trying to set up an export button on a website that will export some information from a database and put it into a .doc file. I'm currently doing this with: </p>
  
  <pre><code>$filename = "File.doc"; 
  
  header('Content-Type: application/octet-stream');    
  header("Content-Disposition: attachment; filename=$filename");
  
  echo "&lt;html&gt;&lt;meta http-equiv=\"Content-Type\" content=\"text/html; charset=Windows-1252\"&gt;&lt;body&gt;&lt;img src='the_img.png' width='250px'&gt;&lt;br&gt;&lt;br&gt;&lt;b style='font-size: 40px;'&gt;&lt;u&gt;&lt;center&gt;Header&lt;/center&gt;&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;&lt;ol&gt;";
  
  $fileData = "SELECT `Songs` FROM `table`;";
  $info = $con-&gt;query($fileData);
  while ($the_row = $info-&gt;fetch_assoc()) {
      $content = $the_row["column"];
  }
  
  $arr = explode("|", $content);
  
  for($i = 0; $i &lt; count($arr); $i++){
      echo "&lt;li&gt;" . $arr[$i] . "&lt;/li&gt;";
  }
  
  echo "&lt;/ol&gt;&lt;/body&gt;&lt;/html&gt;";
  
  mysqli_close($con);
  
  exit;
  </code></pre>
  
  <p>When it exports the .doc file it successfully opens in Microsoft Word, however the image appears to be broken until you enter edit mode. Once you're in edit mode the image has no specific size set. Any suggestions?</p>