Replies: 6   Views: 2566
Set temp_path from code
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 admin  · 30-10-2019 - 07:52


Since the release of phpdocx 6.5, the library only uses the temp_path option to generate charts and download images using the HTML methods. phpdocx 6.5 and newer versions doesn't use this option to generate new documents, as they work with in-memory classes instead of generating a temp DOCX. So we understand this is your case (charts or images from HTML), or ZipArchive (PHP extension) can't work correctly with the default temp folder.

What file or directory is created in the webroot directory? A temp file or the generated DOCX? You can set any destination folder when calling createDocx using absolute or relative paths ( path/route section).

What value do you get when calling sys_get_temp_dir ()? Maybe you could set a custom value using PHP ini options (

If you set the correct temp_path in the INI file the temp path is used correctly? In this case you can init the config before CreateDocx is called. As you have $_phpdocxConfig set as public in PhpdocxUtilities, init the config before creating a CreateDocx object:

PhpdocxUtilities::$_phpdocxConfig['settings']['temp_path'] = 'new value';
$docx = new CreateDocx();

This code replaces the temp_path value before any code of phpdocx runs, so it will work in the same way than setting it using the INI file.

We understand you don't want to change the library but there's no option to change this value dynamically using the current version. A task has been added to be added in the next version of phpdocx.