[英]Output file to server directory in FPDF
I'm using PHP to put together a PDF using FPDF, right at the bottom I have this:我正在使用 PHP 使用 FPDF 将 PDF 放在一起,在底部我有这个:
$pdf->Output("../uploads/filename.pdf",'F');
header("location:../uploads/filename.pdf");
The top line should save the PDF to the uploads folder in the root, and the bottom should show it in the browser.顶行应将 PDF 保存到根目录中的上传文件夹,底行应将其显示在浏览器中。 I get this message:
我收到这条消息:
FPDF error: Unable to create output file: ../uploads/filename.pdf
FPDF 错误:无法创建输出文件:../uploads/filename.pdf
I've even tried making the file path using a variable as suggested in other posts on this site but I still get the same error.我什至尝试使用本网站上其他帖子中建议的变量创建文件路径,但我仍然遇到相同的错误。 I have 777 permissions set throughout the uploads folder too.
我在整个上传文件夹中也设置了 777 个权限。 Thanks.
谢谢。
I've actually figured it out, it's a weird fix but it works.我实际上已经弄清楚了,这是一个奇怪的修复,但它有效。
$path = "../../../../uploads/AAA.pdf";
$pdf->Output($path,'F');
header('location:'.$path);
I had to keep jumping back to the root, then go into the /uploads/ folder specifically.我不得不一直跳回根目录,然后专门进入 /uploads/ 文件夹。 Thanks for the answers so far.
感谢您到目前为止的答案。
$path=$_SERVER['DOCUMENT_ROOT']."/unwant/test3.pdf";
$pdf->Output($path,'F');
use this code easy to save file dir使用此代码轻松保存文件目录
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.