php FPDF 错误“无法创建输出文件”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18515162/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
FPDF error "Unable to create output file"
提问by user2567806
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.
我正在使用 fpdf libray 来提供 pdf 文件。我的项目的一部分包括使用这个库为消费者生成 pdf 文件。我们正在“ovh”下进行服务器测试。“ovh”中我空间的树状结构是:/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 :
一个名为upload 的文件夹,其中包含factures 的文件夹,所有facture 的pdf 文件都在那里。因此,当我尝试在 factures 文件夹中生成 pdf 文件时,它会在网络浏览器中显示我:
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
警告:fopen(upload/factures/facture_98.pdf) [function.fopen]:无法打开流:成功在 /homez.742/coplayer/www/betatest/library/fpdf/fpdf.php 在线 1025
FPDF error:Unable to create output file: upload/factures/facture_98.pdf.
FPDF 错误:无法创建输出文件: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! :)
我尝试了很多我在这个网站上找到的东西,但都不起作用。请帮我。非常感谢!:)
回答by Brewal
Make sure the directory have at least a 755
. Also, use $_SERVER['DOCUMENT_ROOT']
with your path to target the good directory :
确保目录至少有一个755
. 此外,使用$_SERVER['DOCUMENT_ROOT']
您的路径来定位好目录:
$nomFacture = $_SERVER['DOCUMENT_ROOT']."upload/factures/facture_".$idFacture.".pdf";
That will produce something like
那会产生类似的东西
/homez.742/coplayer/www/betatest/upload/factures/facture_12.pdf
/homez.742/coplayer/www/betatest/upload/factures/facture_12.pdf
回答by Ovi Mag
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.
确保你没有发送到输出别的东西(如echo
,var_dump
,等与生成PDF之前)Output("path_file", "F")
。这是强制性的。
回答by Divyesh Jesadiya
make sure that file upload/factures/facture_98.pdfis not open anywhere when you run script. if it's open somewhere else then TCPDF can't open it.
确保运行脚本时文件upload/factures/facture_98.pdf未在任何地方打开。如果它在其他地方打开,则 TCPDF 无法打开它。