FPDF error "Unable to create output file"

user2567806 picture user2567806 · Aug 29, 2013 · Viewed 34.4k times · Source

I'm working with fpdf libray for providing pdf files. A part of my project consists of using this library to generate pdf files for consumers. We are working with a server test under "ovh". The arborescence of my space in "ovh" is : /www/betatest.

A folder named upload which contains factures's folder where all the facture's pdf files will be there. So, when i try to generate a pdf file inside the factures folder, in a web browser it displays me :

Warning: fopen(upload/factures/facture_98.pdf) [function.fopen]: failed to open 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 in this web site but does not work. Please help me. Thank's a lot! :)

Answer

Brewal picture Brewal · Aug 30, 2013

Make sure the directory have at least a 755. Also, use $_SERVER['DOCUMENT_ROOT'] with your path to target the good directory :

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

That will produce something like

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