I have a simple problem but somehow I cannot solve it. I want to create a pdf file and therefore I tried the example provided by Zend (here). When I run the code I get the following error: "PDF error: Can not open 'example.pdf' file for writing". I think the problem are the permissions. But I don't know which file should get the write permission. Instead of just providing every file the permission I wanted to ask if anyone knows what exactly I need to do.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Change the path of the saved file to something like this and make the directory writable.
$pdf->save('path/to/example.pdf');
If you want to be able to overwrite the file use the following:
$pdf->save('path/to/example.pdf', TRUE);
回答2:
you should add something like this to be able to cleanly handle the case of missing write permissions
$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 . '"');
}
标签:
zend-framework