FPDF Error "Unable to create output file"

I am working with fpdf libray to provide pdf files. Part of my project is to use this library to create PDF files for consumers. We are working with a server test under "ovh". The highlight of my space in "ovh" is: / www / betatest.

A folder named upload that contains the fax folder where all the pdf billing files will be located. Therefore, when I try to create a pdf file inside the fax folder, it displays me in a web browser:

Warning : fopen (upload / factures / facture_98.pdf) [function.fopen]: could not open the stream: Success in /homez.742/coplayer/www/betatest/library/fpdf/fpdf.php on line 1025

FPDF Error: Unable to create output file: upload / factures / facture_98.pdf.

I tried a lot of things that I found on this website but it doesn’t work. Please help me. Thanks a lot!:)

+7
source share
3 answers

Make sure the catalog contains at least 755 . Also, use $_SERVER['DOCUMENT_ROOT'] with your path to configure the target directory:

 $nomFacture = $_SERVER['DOCUMENT_ROOT']."upload/factures/facture_".$idFacture.".pdf"; 

This will create something like

/homez.742/coplayer/www/betatest/upload/factures/facture_12.pdf

+5
source

Before creating a PDF with Output("path_file", "F") make sure that you do not send anything else to output (for example, echo , var_dump , etc.). Mandatory.

+1
source

make sure that the upload / factures / facture_98.pdf file does not open anywhere when you run the script. if it opens elsewhere, then TCPDF cannot open it.

0
source

Source: https://habr.com/ru/post/952749/


All Articles