fopen(); "Remote host file access not accepted" on a local file?

user2924019 picture user2924019 · Mar 4, 2015 · Viewed 26.3k times · Source

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". The folder exists, and there are full permissions for "everyone" (Windows).

The code I am using is this:

$pdf->Output('invoices/Delivery Note.pdf', 'F');

This uses fopen to save the file.

However the error I am getting is: Warning: fopen(): remote host file access not supported, file://invoices/Delivery Note.pdf

This is a local file, not a remote one.

I attempted adding a / prefix like this:

$pdf->Output('/invoices/Delivery Note.pdf', 'F');

but then I get this error instead: Warning: fopen(file:///invoices/Delivery Note.pdf): failed to open stream: No such file or directory

I created the file, and left it empty, but the same error as above.

Does anyone know why I am getting this error?

Answer

Gerd picture Gerd · Jun 20, 2015

From php-Script you can use:

$pdf->Output(__DIR__ . '/invoices/Delivery Note.pdf', 'F');