2013-09-16 94 views
0

我正在使用LiveDocx和zend框架從具有值的模板生成word文檔。這是我在我的控制器做:file_put_contents權限被拒絕+ livedocx

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()); 
    } 
} 

但我總是得到錯誤:

Warning: file_put_contents(document.docx): failed to open stream: Permission denied in /var/www/site/application/controllers/ResultsController.php on line 313

正如你可以看到我試着改變使用chmod文件權限,但沒有做招...

我也試圖改變公共文件夾的權限是這樣的:

$path = APPLICATION_PATH . "/../public"; 
chmod($path,0777); 

但相同的R- esult被賦予..

回答

0

你應該嘗試chmod 777

chmod($filename,0777); 
+0

同樣的結果...! – nielsv

+0

您是否嘗試過'chmod'公共目錄? –

+0

剛剛嘗試過,結果相同。更新的開始帖子 – nielsv

0

試圖改變mod目錄文件都喜歡的

$dir=APPLICATION_PATH . "/../public/"; 
$filename = $dir."license-agreement-template.docx"; 
chmod($dir,0777); 
chmod($filename,0777); 

而且文件的名稱其中你想要把內容應該是$filename

file_put_contents($filename, $document); 

地方

file_put_contents('document.docx', $document);