2010-09-23 65 views
1

我有一個簡單的問題,但不知何故我無法解決它。我想創建一個pdf文件,因此我嘗試了Zend提供的示例(here)。當我運行代碼時,出現以下錯誤:「PDF錯誤:無法打開'example.pdf'文件進行寫入」。 我認爲問題是權限。但我不知道哪個文件應該獲得寫入權限。而不是僅僅提供每個文件的權限,我想詢問是否有人知道我需要做什麼。Zend PDF - 權限問題

回答

1

將保存文件的路徑更改爲類似這樣的內容,並使目錄可寫。

​​

如果您希望能夠覆蓋該文件使用以下命令:

$pdf->save('path/to/example.pdf', TRUE); 
0

你應該添加這樣的事情能夠乾淨利落處理缺少寫入權限

$path = 'path/to/example.pdf'; 
$folder = dirname($fileToWrite); 
if (!is_dir($folder) || 
    !is_writeable($folder) || 
    (file_exists($path) && !is_writeable($path)) { 

    throw new Exception('The server admin does not allow you to write the file. ask him to give you the required permissions to write "'. $path . '"'); 
} 
的情況下,