Replies: 2   Views: 3110
Image not appearing in the word document.
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by fueldigital-dev  · 13-03-2013 - 07:20



When i tried to insert an image into the word document, the images where not appearing.

I could see a blank page for that image.

I use custom build function to loop through the glob to look for all images and split to the word.

function images($docx,$field1,$field2,$inspector_name,$inspector_session)
$inspection_type = "BuildingReport-";
$folder_final = 'uploads'.'/'.$inspector_name.'/'.$inspector_session.'/'.$inspection_type;

// Scanning the thumbnail folder for JPG images:
$g = glob($folder_final.'/original/*.jpg');

$g = array();
$names = array();
$section = array();
$modified = array();

// We loop though the file names returned by glob,
// and we populate a second file with modifed timestamps.
$image_section = $field1;
$j = 1;
$imageString = '';

$imageString .= "<img width=\"300\" height=\"225\" src=\"".$g[$i]."\"><br><br>";
$imageStringArr[] = "<img src=\"".$g[$i]."\">";

$docx->addTemplateVariable($field2, '');

Can you please tell me what i am doing wrong. Is there any alternative functions that i could use ?

Posted by admin  · 11-04-2013 - 12:13


This code:


allows you replace a placeholder using HTML code. You should use:


that transform the image to MHT, or replaceTemplateVariableByHTML method using an img tag.