-
Notifications
You must be signed in to change notification settings - Fork 132
Can not write to temp directory #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hmm, sounds weird. I'd still assume a permission problem with |
I saw the file allready created in the /tmp folder. However: the command failed. |
Well, can you inspect the file? XFDF is an XML format, thus text based. |
Yup, I even copied the executed command generated on /vendor/mikehaertl/php-shellcommand/src/Command.php:321 |
Sorry, misread your answer. So it seems, that when executing Sorry, I can't help you much more here. You should try to find out, what permission restrictions are active on the system. Also maybe do some tests with |
Okay, I now know what the error is. However to install pdftk on a recent version of ubuntu is using snap. this will install it in a secure way so that it doesn't have access to the /tmp folder. That's why it's failing out of the box
This works. Maybe to put in your readme ? to avoid using the snaps (or you should rewrite parts of your code to generate fdf files outside of the /tmp folder |
Hmm, yeah, I'm also using the version from malteworld. I've added a note to the README. |
I'm just noting that I also ran into the problem that pdftk-from-snap-is-failing because it can't access the temp directory. |
Im having this issue now on the latest Homestead. Any ideas? Totally lost, /tmp seems to be writeable so I dont get the issue. |
@robmpreston The issue is that the snap format improves safety and security by whitelisting filesystem access to particular directories. Apparently the snap package for pdftk lacks permission to create tmp files, badly breaking it. This assumes you are using the |
Would it help to make the temp directory configurable? Without looking at the code I think this is currently not so easy. I could add a feature that you can pass options to the underlying https://github.com/mikehaertl/php-tmpfile . |
I've copied a part of my after.sh script of my homestead installation. might provide you with a start to a solution...
|
I have this strange issue too,my tmp folder's chmod is 777 but not even this case is possible to write to there by pdftk |
I don't understand why did you close this issue if it not solved. The command is :
when i run it from the terminal i got this:
Remove a few words from the command: What makes the error is This is what i know already but i am busy now with other things to solve totally. |
snap only access to user's home directory |
@Avemaar There's now a PR, where I've added an option that makes the temporary directory configurable: $pdf = new Pdf('/some/file.pdf');
$pdf->tempDir = '/home/mike/temp'; Can you (or anyone interested) help testing this please? I still see people struggle to find a writeable directory. But that's really out of the scope of this library. We need a writeable directory or things just don't work. The library can't solve this. |
If you want to test it you can install the version from the PR with this command:
|
I am also running into the same error (using Laravel also). Not sure if this is helpful, but I get the following when debugging using Local Environment
Other Server
Even though it's the same code in each case, I do notice that there's an additional Note: Tried it with the dev-master version from the previous comment. |
Following the suggestions above, manually setting the tempDir resolved the error. For those using Laravel Forge, this would look something like: On the server: cd /home/forge
mkdir tmp and then in the code: $pdf = new Pdf('/some/file.pdf');
$pdf->tempDir = '/home/forge/tmp'; Although now there is unrelated issue I'm currently wrestling with:
But I think that may because pdftk was installed using snap. This will require further debugging. |
@jimhlad Let's summarize:
I've just released 0.8.0 including this change. |
worked for me too.... |
Thanks @PaulMenheere , that command resolved the second issue I was having! Combined with the code tweaks @mikehaertl made, I can confirm I am now able to fill & generate PDF forms. I feel like I got insanely lucky with the timing here. Ran into this issue in the afternoon and then was surprised to see that there was already a PR an hour earlier. Thanks again! |
okey i solved the issue, the php can not run pdftk command because the www-data has no permission to run script |
@PaulMenheere's repo doesn't contain that package anymore |
Hello, everybody. I'm a junior developer. $pdf = new PdfTk(storage_path().'/app/modelli/registri/registro_presenze.pdf', $file = $pdf->getTmpFile(); |
I found the solution. I was wrong to give permission to the tmp folder ;-) |
Here's an update:
|
Whenever I try to fill in a form using fillForm I get an error message stating
Error: Failed to open form data file: \n /tmp/php_pdftk_xfdf_uL6Hf2.xfdf\n No output created.
code:
$tempPdf = new \mikehaertl\pdftk\Pdf(__DIR__ . '/Mededelingsformulier_scheiding_2019_2.pdf'); $tempPdf->fillForm($arr = [ 'test' => 'test', ]); $tempPdf->saveAs(__DIR__ . '/tempfile.pdf'); $error = $tempPdf->getError(); $this->assertEquals('', $error);
All files are accessible, other functions work perfectly (getDataFileds, GenerateFdf)
I'm working with Laravel running on an updated Homestead vagrant instance using pdftk from a snap install.
The text was updated successfully, but these errors were encountered: