PHP TCPDF ERROR: Unable to create output file the folder exist and has the right permissions

Daniele picture Daniele · Dec 23, 2013 · Viewed 18.6k times · Source

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?

Answer

Atul Baraiya picture Atul Baraiya · Sep 16, 2015

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