-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hi,
this is a shortcoming of the current file upload. there is an ugly hack to make it "just work" for now, and some more info in this thread: http://groups.google.com/group/symfony-devs/browse_thread/thread/f6ee02520e244c96/973d3cc5ac59cee5?lnk=gst&q=file+upload#973d3cc5ac59cee5 cheers,david Am 04.04.2011 20:58, schrieb spike3111: > Hello, > > I have a form to send pictures, but when I want to display picture it > doesn't work: > > class PhotosForm extends Form > { > public function configure() > { > $this->setDataClass('Nt\\SocialBundle\\Entity\\Photos'); > $this->add('nom'); > $this->add(new FileField('filename', > array( > 'secret' => md5("file"), > 'tmp_dir' => 'bundles/ntsocial/images' > ))); > } > > My controller to show pictures: > > public function showPhotosAction($name) > { > $em = $this->get('doctrine.orm.entity_manager'); > $user = $this->findUserBy('username', $name); > > $dql = "SELECT u FROM Nt\SocialBundle\Entity\Photos u". > " WHERE u.photosU = ?1"; > > $query = $em->createQuery($dql); > $query->setParameter(1, $user->getId()); > > $return = $query->getResult(); > > return array('photos' => $return); > } > > And the view: > {% block content %} > {% for photo in photos %} > <div> > <p>{{ photo.nom }}</p> > <img alt="{{ photo.nom }}" src="{{ photo.filename }}"> > </div> > {% endfor %} > {% endblock %} > > The html: > <div> > <p>test</p> > <img alt="gtgt" src="C:\sf9\web\bundles\ntsocial\images > \ec977c68cd42e9fc011dfcdb39abfa85"> > </div> > > and controller to add a picture: > > public function addPhotoAction($name) > { > $em = $this->get('doctrine.orm.entity_manager'); > $user = $this->findUserBy('username', $name); > > $photo = new Photos(); > > $request = $this->get('request'); > $form = PhotosForm::create($this->get('form.context'), > 'Photos'); > > $form->setData($photo); > > if ($request->getMethod() == 'POST') { > $form->bind($request); > $photo->setPhotosU($user); > > if ($form->isValid()) { > $em->persist($photo); > $em->flush(); > > return $this- >> render('NtSocial:Social:addPhoto.html.twig', array('form' => $form)); > } > } > > return $this->render('NtSocial:Social:addPhoto.html.twig', > array('form' => $form)); > } > > Thank you ! > - -- Liip AG // Agile Web Development // T +41 26 422 25 11 CH-1700 Fribourg // PGP 0xA581808B // www.liip.ch -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk2asZgACgkQqBnXnqWBgIut3QCcCe2sSPED7RS88YLh0jzO2KUe nYUAoKDHcyfWR0nlEUcNMJrSriRrfYSR =MtMf -----END PGP SIGNATURE----- -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en