FPDF error “Unable to create output file”

孤人 提交于 2019-12-09 03:10:54

问题


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


回答1:


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




回答2:


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.




回答3:


make sure that file upload/factures/facture_98.pdf is not open anywhere when you run script. if it's open somewhere else then TCPDF can't open it.



来源:https://stackoverflow.com/questions/18515162/fpdf-error-unable-to-create-output-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!