phppathtcpdflampp

TCPDF unable to output file by saving. Path on Mac?


I checked some similar questions here, but i didn't got an answer, solving my problem.

I use TCPDF to generate a PDF with PHP.

When I use the $pdf->Output($file_total, 'I'); it's all good and the file is shown in Browser.

If I use the save to localhost option $pdf->Output($file_total, 'F'); I get this error:

"failed to open stream: Permission denied in /opt/lampp/htdocs/project/tcpdf_min/include/tcpdf_static.php on line 1821" "TCPDF ERROR: Unable to create output file"

The Path I set for saving the PDF file is: "/opt/lampp/htdocs/project/files/2021"

What am I doing wrong? is my path wrong?

The forced saving $pdf->Output($file_total, 'D'); works just fine, so i must doing something wrong with the path on mac... please help!

Thanks


Solution

  • In comments we both went through possible reasons such as finding an absolute rather than relative location and checking out folder permissions for non admin process as that was also suspected. Thus between us the conclusion was:-

    use address as

    "localhost:8080/projects..."

    and ensure target folder was set to permissions

    "read/write" for all users

    For production use the write access needs to be trimmed back to the process and admin, not all users.