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

Created on 31 May 2016  路  4Comments  路  Source: PHPOffice/PHPWord

Fatal error: Uncaught exception 'PhpOffice\PhpWord\Exception\CreateTemporaryFileException' with message 'Could not create a temporary file with unique name in the specified directory.' in /var/www/d0gmatist/data/www/d0gmatist.pro/engine/modules/blanks/PhpWord/TemplateProcessor.php:76 Stack trace: #0 /var/www/d0gmatist/data/www/d0gmatist.pro/engine/ajax/blanks/blanks_generator.php(78): PhpOffice\PhpWord\TemplateProcessor->__construct('/var/www/d0gmat...') #1 {main} thrown in /var/www/d0gmatist/data/www/d0gmatist.pro/engine/modules/blanks/PhpWord/TemplateProcessor.php on line 76
What's my mistake?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Most helpful comment

Hi, did you found a solution for this problem?

upd:
Well, after hours of attempts I fixed it:
There could be few reasons:

  1. Not enought permissions on operation folder (you need to put recousively 775 permission to make it work)
  2. Check the owner and owner-group of this folder, maybe current user doesn't have permission to read/write in current folder, also could be fixed by providing extra permissions to folder (777)
  1. Check your tmp folder, if it's also writable or not. In internet there are a lot of variants how to do it, in my case, I have just change path to tmp folder in vendor/phpoffice/phpword/src/Settings.php, function getTempDir(), I have hardcoded absolute path of current working directory and problem was gone. But probably it's not best idea.

All 4 comments

Surely no one knows the cause of the error?

Hi, did you found a solution for this problem?

upd:
Well, after hours of attempts I fixed it:
There could be few reasons:

  1. Not enought permissions on operation folder (you need to put recousively 775 permission to make it work)
  2. Check the owner and owner-group of this folder, maybe current user doesn't have permission to read/write in current folder, also could be fixed by providing extra permissions to folder (777)
  1. Check your tmp folder, if it's also writable or not. In internet there are a lot of variants how to do it, in my case, I have just change path to tmp folder in vendor/phpoffice/phpword/src/Settings.php, function getTempDir(), I have hardcoded absolute path of current working directory and problem was gone. But probably it's not best idea.

Thanks @Hiros101 my problem was solved with the solution number 3. I lost a lot of time with this error.

@chrismedrdz Can u help me? Show me the path bro?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ahmednawazbutt picture ahmednawazbutt  路  3Comments

igorsantos07 picture igorsantos07  路  3Comments

totpero picture totpero  路  6Comments

akashraiesoft picture akashraiesoft  路  4Comments

ortegacmanuel picture ortegacmanuel  路  6Comments