i'm using symfony 2.5 & Php 5.3 ( old server )
i just want to add an input file in my form to display his pathname like (C://pathto/filename)
I've added an attribute in my class Advert.php like that :
/**
* @ORM\Column(type="string", nullable=true)
*
*/
private $brochure = null;
public function getBrochure()
{
return $this->brochure;
}
public function setBrochure($brochure)
{
$this->brochure = $brochure;
return $this;
}
and in my AdvertType.php :
->add('brochure', 'file', array(
'required' => false,))
But i think i'm missing something in my addAction because it returns me a bad path like : (/tmp/phpYAVwMQ) instead of (C://filename.pdf) when displaying {{ advert.brochure }}
public function addAction(Request $request)
{
$advert = new Advert();
$form = $this->createForm(new AdvertType(), $advert);
$usr = $this->get('security.context')->getToken()->getUser();
if ($form->handleRequest($request)->isValid()) {
$em = $this->getDoctrine()->getManager();
$advert->setAuthor($usr->getUsername());
$advert->setDate(new \DateTime);
$em->persist($advert);
$em->flush();
$request->getSession()->getFlashBag()->add('info', 'Annonce bien enregistrée.');
// On redirige vers la page de visualisation de l'annonce nouvellement créée/
return $this->redirect($this->generateUrl('info_view', array('id' => $advert->getId())));
}
return $this->render('SocietyPerfclientBundle:Default:add.html.twig', array(
'form' => $form->createView(),
));
}
Please help me :)