Cannot Save File to directory using FPDF

此生再无相见时 提交于 2019-12-21 20:24:03

问题


I won't break out or show the lengthy code in actually building the PDF itself because I know the file generation is working fine.

When I try the following:

$pdf->Output('abc.pdf', 'F');

I receive error:

FPDF error: Unable to create output file: abc.pdf

By changing the Output destination to 'D' or 'I':

$pdf->Output('abc.pdf', 'D');

The user is prompted to download the pdf that was generated and is done so successfully (views fine). The error makes me think it is a permissions error but fpdf should have access to write a pdf file to the directory the action is already occurring in correct?

Anybody dealt with this before?


回答1:


If your PHP script is executed from a web-page (served by Apache, it is), then this code will be executed by the Apache (sometimes called www-data) user.

So, your Apache user needs to be able to write to the directory you're trying to write to.


Typically, you might have to give the write privilege to the other users of your system, using something like this from a command-line :

chmod o+w your_directory


The software you're using to upload your source files, if doing so using a GUI, should allow you to do that with a couple of chekboxes -- you need to check the "write" checkbox for the "others" users.




回答2:


chmod o+w your_directory fixed it for me :)



来源:https://stackoverflow.com/questions/5736965/cannot-save-file-to-directory-using-fpdf

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