开发者

Zend PDF - Permission problem

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 Z开发者_Python百科end (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.


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


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 . '"');
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜