I am using the Tcpdf module and PHP to create dymanic PDF invoices from an ordering system.
The script should then save the invoice into a folder called \"invoices\"
I suggest using the following as Gerd has also suggested but make sure you use an absolute path:
$pdf->Output(__DIR__ . '/invoices/Delivery Note.pdf', 'F');
The path must be an absolute path & not a relative path. This PHP bug report explains why: https://bugs.php.net/bug.php?id=28820
The reason relative paths are not supported with the file:// wrapper comes down to a compromise in how UNC paths are dealt with (and more specifically how / are fuzzily interpreted as \ for windows installations).
For Example:
file://foo/bar
Could be interpreted as a relative URI: foo/bar from the current working directory, OR it could be interpreted as a UNC: \foo\bar (share
baron computerfoo).For this and a few internal reasons the file:// wrapper is limited to absolute paths when called explicitly. For relative paths either use realpath() {as you did in your report}, or omit the explicit naming of the file wrapper.
You can then avoid modifying the TCPDF code and worrying about any upgrades replacing your modified code.