Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FPDF error "Unable to create output file"

Tags:

php

fpdf

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! :)

like image 674
user2567806 Avatar asked Aug 29 '13 15:08

user2567806


2 Answers

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

like image 104
Brewal Avatar answered Oct 04 '22 02:10

Brewal


Make sure you have not sending to output something else (like echo, var_dump, etc.) before generating PDF with Output("path_file", "F"). It is mandatory.

like image 29
Ovi Mag Avatar answered Oct 04 '22 00:10

Ovi Mag