Forum


Replies: 2   Views: 2833
Issue with addchart examples of phpdocx
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 andrzej.morun  · 30-03-2017 - 22:44

Any example with addchart give error:

Error while trying to write to .docx please check write access.

http:// (...) /phpdocx/examples/Core/addChart/sample_1.php

Failure to create temporary file: Permission denied in /home/(...)/phpdocx/classes/DOCXStructure.inc on line 136

Looking for code od DOCXStructure.inc I think that problem is $path is empty.

This code add '.docx' which is displayed in error.       

// check if the path has as extension
        if(substr($path, -5) !== '.docx') {
            $path .= '.docx';
        }

 

What maybe wrong? What can I do? Others method of phpdocx works. I can read temaplete. Replace text variable. But I I want to add chart this causes exception.

I have checked any different configuration of temp_path. Leave empty, set "/tmp/". Any option didn't resolve problem.

Posted by admin  · 31-03-2017 - 06:45

Hello,

The DOCXStructure class is used by all samples and any file created by phpdocx, so if other scripts work then the problem may come from other source. The addChart method uses the default temp dir to create a chart temp file, maybe it can't write to this folder.

Please try to run the included sample examples/Core/addChart/sample_1.php using PHP CLI mode:

$ php sample_1.php

phpdocx uses tempnam to get the temp folder when using addChart, if you echo this PHP function:

echo tempnam('', 'chart');

you can get the default temp folder to check if you have rw access.

We also see you have written other topics in the forum about charts and you were able to create them. Have you changed anything in the server configuration?, or have you moved the library to other server?, maybe the server logs can help to explain this issue.

Regards.

Posted by andrzej.morun  · 01-04-2017 - 20:50

The problem was caused by maximum limit of files in temp directory.

Thank you for answer..