我正在使用 LiveDocx 和 zend 框架从带有值的模板生成 word 文档。这就是我在控制器中所做的:
public function createwordAction(){
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
require_once 'Zend/Service/LiveDocx/MailMerge.php';
try{
$filename = APPLICATION_PATH . "/../public/license-agreement-template.docx";
chmod($filename,0777);
$mailMerge = new Zend_Service_LiveDocx_MailMerge();
$mailMerge->setUsername('******')
->setPassword('*******');
$mailMerge->setLocalTemplate($filename);
$mailMerge->assign('software', 'Magic Graphical Compression Suite v1.9')
->assign('licensee', 'Henry Döner-Meyer')
->assign('company', 'Co-Operation')
->assign('date', 'January 11, 2010')
->assign('time', 'January 11, 2010')
->assign('city', 'Berlin')
->assign('country', 'Germany');
$mailMerge->createDocument();
$document = $mailMerge->retrieveDocument('docx');
file_put_contents('document.docx', $document);
}
catch (Exception $e) {
die ('Application error: ' . $e->getMessage());
}
}
但我总是得到错误:
警告:file_put_contents(document.docx):无法打开流:第 313 行 /var/www/site/application/controllers/ResultsController.php 中的权限被拒绝
如您所见,我尝试使用 chmod 更改文件权限,但这并没有成功...
我还尝试像这样更改公用文件夹的权限:
$path = APPLICATION_PATH . "/../public";
chmod($path,0777);
但是给出了相同的结果..