I checked some similar questions here, but i didn't got an answer, solving my problem.
I use TCPDF to generate a PDF with PHP.
When I use the $pdf->Output($file_total, 'I');
it's all good and the file is shown in Browser.
If I use the save to localhost option $pdf->Output($file_total, 'F'); I get this error:
"failed to open stream: Permission denied in /opt/lampp/htdocs/project/tcpdf_min/include/tcpdf_static.php on line 1821"
"TCPDF ERROR: Unable to create output file"
The Path I set for saving the PDF file is: "/opt/lampp/htdocs/project/files/2021"
What am I doing wrong? is my path wrong?
The forced saving $pdf->Output($file_total, 'D'); works just fine, so i must doing something wrong with the path on mac...
please help!
Thanks
In comments we both went through possible reasons such as finding an absolute rather than relative location and checking out folder permissions for non admin process as that was also suspected. Thus between us the conclusion was:-
use address as
"localhost:8080/projects..."
and ensure target folder was set to permissions
"read/write" for all users
For production use the write access needs to be trimmed back to the process and admin, not all users.
Related
I am working with PDFlib's php code in an aws server and I keep getting he following error message
Couldn't open PDF file 'file.pdf' for writing (permission denied)
I considered editing the permissions of this particular directory but the permissions are
drwxrwxrwx+
Which seem to be appropriate for this script to function. Anyone has any idea why I am getting this permissions error?
Thank you for the input I have discovered the error.
My issue was that I was not specifying the path to my output document and temp directory.
I was declaring my output document as :
$output_document = "file.pdf"
instead of
$output_document = "/path/to/output/file.pdf"
I need to connect my mamp-Database with the craftcms files, in order to create a new website.
I put all the files for the installation of craft in the requested files. As I wanted to open the link for creating the new page, i got the error message:
The file structure you can see in the images below.
how do I change the file path correctly? Or how do I change the file structure, so the host will find it?
Thanks very much for you answer in advance
I created a page for users to download certain files. I used the HTML download link to do this as so:
<a download href="/home/Uploads/someDir/someFile.PNG" >View</a>
This worked fine when I was developing on my laptop with WAMP. When I uploaded the code to our Centos 7 Server it did not work. I changed the Uploads, someDir, and someFile.PNG permissions to 777. I also made sure that the file path was correct. But the when the download link is pressed the file icon at the bottom of the screen says "Failed no file".
Maybe I need to do more with the permissions. I know that the folder that the html file is in has restricted permissions, but I would prefer to keep them that way. I do not know how that could cause an issue.
I am looking for debugging tips/possible causes. At this point I am clueless where to look.
The issue with the download not working is simply due to the fact that the path to your file is wrong. My advice on your root directory which is in most cases is var/www/html, create a folder called say somefoldername and manually upload the file to that folder then change the download link to be
View.
"Failed no file" has nothing to do with permissions. The path to your download file has most likely changed when the files were uploaded to the server. You should manually check to see if the file at
/home/Uploads/someDir/someFile.PNG
actually exists. If not you can change the link accordingly or move the download file to the appropriate location.
Another good alternative to solve this error is to put a dot '.' at the beginning of the url:
<a download href="./someDir/someFile.PNG" >View</a>
This way you will not need to indicate the complete url.
And if in the future the url changes, you won't have to modify the url.
In my case it works perfect, I hope it helps you too.
Just check the directory in which you are trying to fetch the file. Your looking file may be not present in that directory. Otherwise, you are using the correct piece of code.
<a download href="~/home/Uploads/someDir/someFile.PNG" >View</a>
I have created a php file which will open a text file(which resides in the same location along with the php file),and i also added some code thus i can change the content of the text file.It was working great in my local host but as soon as i upload the folder to a server i cant save the changed content to the file some permission related error is coming up.Is there any way thus i can forcefully change the content of the file in server?I mean is there any way thus this permission related issues can be overcome?
Access it via FTP and change the permissions to 755 which allows everyone to read / execute and only yourself to write.
Read more about permissions to find what best suits your requirements.
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?
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.
chmod o+w your_directory fixed it for me :)