Forum


Replies: 2   Views: 252
Dynamic variable while using replaceplaceholderimage
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 Dale.Cooper  · 29-04-2024 - 09:25

Hi!

I have the following code in use:

$qrcode_id = $_POST['qrcode_id'];

$image_options = array(

    'height' => 2,

    'width' => 2,

    'target' => 'header',

);

$docx->replacePlaceholderImage('QRCODE', 'docs/'.$qrcode_id.".png" , $image_options);

$docx->createDocx('docs/'.$filename);

 

But I have a problem with the dynamic file url. If i use it like above, the Word Doc is broken and can't be opened. When using hard coded file path, it works. Also I tried to create the filepath first and save it to another variable and put only a variable into the replacePlaceholderImage function, but it makes no difference. Am I missing something here what might cause to break the creation of the word file while using dynamic paths?

- I've checked the dynamic handover for $qrcode_id, that's coming in correct
- The needed PNG file is on the server and readable - and it works when using the hard coded path.

 

Thank you for any tips!

 

Marc