我正在使用bundle中的基本代码生成pdf并且浏览器输出正常工作。 (控制器)
public function fileAction($name, Request $request)
{
$format = $this->get('request')->get('_format');
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('TestBundle:Kunden')->find($name);
return $this->render(sprintf('TestBundle:Kunden:file.%s.twig', $format), array(
'name' => $name,
'entity' => $entity,
));
我想将文件保存在上传文件夹中,所以我尝试了在文档或其他帖子中找到的代码。 (控制器)
public function pdfAction($name)
{
$format = $this->get('request')->get('_format');
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('TestBundle:Kunden')->find($name);
$facade = $this->get('ps_pdf.facade');
$response = new Response();
$this->render(sprintf('TestBundle:Kunden:file.%s.twig', $format), array('entity' => $entity,'name' => $name,), $response);
$xml = $response->getContent();
$content = $facade->render($xml);
return new Response($content, 200, array('content-type' => 'application/pdf'));
}
我知道我错过了什么,但我不知道在哪里可以定义路径或文件名。如何从上传文件夹中的fileAction()保存生成的pdf?