PHPword error Could not create a temporary file

the error message is as follows:

Could not create a temporary file with unique name in the specified directory.

error file:

TemplateProcessor.php line 79
Oct.11,2021

(1) there is no permission to operate the folder (you need to give up 775 permissions to make it work)
(2) check the owner and owner group of this folder, maybe the current user does not have read / write permission to the current folder, or you can repair it by providing additional permissions for the folder (777)
(3) check your tmp folder if it is also writable. There are many variants on the Internet how to do, in my case, I just changed the path to the tmp folder in the vendor / phpoffice / phpword / src / Settings.php, function getTempDir (), I have hard-coded the current absolute path to the working directory and the problem is gone. But maybe it's not the best idea.


find the line of code in which you want to create a file, usually that directory is not configured correctly or does not have writeable permissions.

Menu