PHP TCPDF ERROR: Unable to create output file the

2019-05-09 23:22发布

I'm trying to save a pdf file using the html2pdf PHP class. The code is this:

$this->html2pdf->Output('directory/file_name.'.pdf', 'F');

But I have alway this error TCPDF ERROR: Unable to create output file

the folder 'folder' (the name is an example, obviusly), exist and has the right permissions!

I tryed to omit the folder name, but this error appear anyway...

Anyone can help me?

5条回答
成全新的幸福
2楼-- · 2019-05-09 23:34

If you already tried al these things, try

sudo setenforce 0

Worked for me!

Jannes

查看更多
等我变得足够好
3楼-- · 2019-05-09 23:39

thats because your folder dont have proper permissions.change your directory permissions. in linux you will do this like mentioned below.

 chmod -R 0777 /yourdirectory
查看更多
迷人小祖宗
4楼-- · 2019-05-09 23:39

make sure that your file('directory/file_name.'.pdf') is not open anywhere when you run script. if it's open somewhere else then TCPDF can't open it.

查看更多
我想做一个坏孩纸
5楼-- · 2019-05-09 23:43

In the 'include/tcpdf_static.php' file about 2435 line in the static function 'fopenLocal' if I delete the complete 'if statement'... works fine.

public static function fopenLocal($filename, $mode) {
  /*if (strpos($filename, '://') === false) {

    $filename = 'file://'.$filename;
  } elseif (strpos($filename, 'file://') !== 0) {
    return false;
  }*/
  return fopen($filename, $mode);
}
查看更多
手持菜刀,她持情操
6楼-- · 2019-05-09 23:53
$pdf->Output(APP . 'webroot' . DS . 'files' . DS . 'pdf' . DS . 'filename.pdf', 'F');

Try this ...

查看更多
登录 后发表回答