Forum


Replies: 1   Views: 319
.htaccess and images
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 apack  · 23-01-2024 - 00:10

Dear PHPDOCX-folks.

I am creating a Word file from a html-string with images embedded as "<img src='../images/1234.jpg' />". Now I have protected the webspace with the .htaccess and .htpassw method (one can only go to the website after userID and PW are given in the browser). Since I have done this, my Word files are still created but after downloading them all images are missing. Without the .htaccess restriction all images are in the Word file. My feeling is that phpdocx need "free access" to the images on the server.

Any idea to come around (I want to keep the .htaccess restriction).

Thanks, Andreas

PS: Images work fine when being embedded in a template docx.

Posted by admin  · 23-01-2024 - 07:39

Hello,

UPDATE: phpdocx 15 includes a streamContext option to set a stream context to download images from HTML.

Yes, phpdocx needs public images to be able to download and add them to the document.

Maybe you could add an exception in the htaccess and protect all IPs but the public IP where phpdocx runs. Or generate a custom script that downloads the HTML with the images from your server, and then add this content using phpdocx methods.

The testing branch includes a new option in embedHTML and replaceVariableByHTML to set a stream context when downloading the images. This option could be used to set a stream context with the required HTTP authorization. Please note that this option is not available in the current stable release, and only users with active LUS can get testing features.

Regards.