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"
Related
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.
Another dev and I are creating a website and we are using php to read/write to/from our site's directory. For some reason, everything on his end works fine but I can only get one type of I/O to work... If I modify my httpd.conf file and change the user:
User _www //Change this to my system user name (Spencer)
Group _www
I can upload image files to our directory, but as soon as I make that change, I can no longer read text files which causes an exception:
Uncaught SyntaxError: Unexpected token <
on this line:
var results = $.parseJSON(data);
If someone could help me better understand the relevant portion of the httpd.conf file I included above and help me with a direction for improving my setup, I would be very appreciative!
EDIT:
When I add a console.log(data) before the json parse, the output is <b>Warning</b>: chmod(): Operation not permitted in <b>/Users/Spencer/Programming/... and the error contains the text of the file I'm trying to open..
After digging into it more, it turns out this is what is causing the problem:
chmod($fileName, 0777);
and I guess that is a problem because the PHP user and the System user clash. I found some info about PHP and the chmod() function here
Removed irrelevant code
Can someone help me with this I am getting the following message when trying to use MPDF
include(/var/www/svn_data/skeletonapp/mpdf/ttfontdata/dejavuserifcondensed.mtx.php): failed to open stream: No such file or directory
I have chmod'ed the correct files ttfontdata, tmp and graph_cache
It seems like the system has to generate the files but its not.
Thanks,
Ross.
The problem is that directory ttfontdata/ is not writable for the process under which the PHP code is running. MPDF needs to generate and write some files there.
Simplest solution is:
chmod 777 ttfontdata
I have a code which would copy a file from one location to another.When I try to access the copied file,I am receiving file not found error,but the file is actually present in that location.
Location of source file:codebase\assets\default_pages\
Location of file to be copied:codebase\site_users\general\test\
Source file:home.php
Destination file:test.php[Rename while copying]
Code:Test.php[location:codebase\models\user_entry\]
copy("../../assets/default_pages/home.php","../../site_users/general/test/test.php");
When I try to access test.php,it gives me following error,
/codebase/site_users/general/ravikanth/codebase/site_users/general/test/test.php
But when I create a file manually[without code]everything works fine.Thanks in advance for your help.
i think you must be having some sort of redirect inside your php file.
can you paste the content of the file which your trying to access after copying
It could be a simple file permission problem. Try chmod command. Maybe manually you are creating/copying with root but Apache or whatever the PHP runs on does not have a permission.
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.