Reputation: 1027
I'm working with the KnpSnappyBundle
and on trying to create a PDF I get the 500 error Warning: mkdir(): Permission denied
I've looked around and found answers for this questions but they don't seem to specifically relate to the built-in server. I do think that this is a file permissions error but I do not know how to resolve it.
For context, below is the code that is triggering the error:
/**
* @Route("/", name="home")
*/
function mainOverview() {
return new Response(
$this->get('knp_snappy.pdf')
->generate(
'http://www.google.fr',
'/pdf/test.pdf' // **500 error triggers here**
),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="file.pdf"'
)
);
}
Clarified that this is probably a file permissions error, rather than a coding error.
Upvotes: 1
Views: 1009
Reputation: 7033
The permission error is due to the fact that the owner of the process , the symfony server, does not have the permission to create folder under the root directory /
$this->get('knp_snappy.pdf') ->generate( 'http://www.google.fr', '/pdf/test.pdf' // 500 error triggers here )
So please change the directory where you generate pdf from '/pdf/test.pdf' to your home directory (~/define/your/path) or where you have permission to create destination directory solve this issue
Upvotes: 1