私は LiveDocx と zend フレームワークを使用して、値を持つテンプレートから単語文書を生成しています。これは私がコントローラーで行うことです:
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);
しかし、同じ結果が得られました..