私が使用していsymfonyの2.5 &のPHP 5.3(旧サーバー)Symfony2の入力ファイル
私は(C:// pathto /ファイル名)のような彼のパス名を表示するには、私のフォームで入力ファイルを追加したい
私はそのような私のクラスAdvert.php内の属性を追加しました:
/**
* @ORM\Column(type="string", nullable=true)
*
*/
private $brochure = null;
public function getBrochure()
{
return $this->brochure;
}
public function setBrochure($brochure)
{
$this->brochure = $brochure;
return $this;
}
と私のAdvertType.phpで:
->add('brochure', 'file', array(
'required' => false,))
しかし、私はそれのように私に悪いパスを返しますので、私は私のaddActionで何かが欠けていると思う:{{ 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(),
));
}
を表示する場合:(//filename.pdf C)
(は/ tmp/phpYAVwMQ)の代わりに、
私を助けてください:
おかげで多くを@ルアックス、最高だよ! <3 –