Nope. Thats symfony 1. For Symfony 2 1. Add an Entity class with a file property. Provide some validation data for specific mime-types and file size. namespace WeatherVane\SyncBundle\Entity; class UploadedData {
/** * @validation:File( * maxSize = "10M", * mimeTypes = { * "application/zip", * "application/x-zip" * } * ) */ private $zipFile; public function setZipFile($zipFile) { $this->zipFile = $zipFile; } public function getZipFile() { return $this->zipFile; } } 2. Add a form class using a fileInput. namespace WeatherVane\SyncBundle\Form; use Symfony\Component\Form\FileField; use Symfony\Component\Form\Form; class DataForm extends Form { protected function configure() { $this->add(new FileField('zipFile', array('secret' => md5(time())))); parent::configure(); } } 3. Use the form in your controller public function indexAction() { $uploadedData = new UploadedData(); $form = DataForm::create($this->get('form.context'), 'uploadedData'); $form->bind($this->get('request'), $uploadedData); if($form->isValid()) { $this->get('session')->setFlash('notice', 'Success'); move_uploaded_file($uploadedData->getZipFile(), '/my/ location/'); } return $this->render('ACMEBundle:Default:index.html.twig', array( 'form' => $form )); } On Apr 14, 1:22 am, Laxmi <laxmipsa...@gmail.com> wrote: > hear is the code i used to upload image > > $dir = sfConfig::get('sf_web_dir').'\images\user\ '; > > $filename = $_FILES["file"]["name"]; > > move_uploaded_file($_FILES["file"]["tmp_name"],$dir.$filename); > > On Apr 13, 12:40 pm, Carl <carl.par...@gmail.com> wrote: > > > > > > > > > I'm not aware of anything built-in that takes care of file uploads but it > > probably wouldn't be too difficult to incorporate the HTTP_Upload PEAR > > package into your project: > > >http://pear.php.net/package/HTTP_Upload > > > Unfortunately, it's no longer maintained (at the moment anyway), but I've > > never really had issues with it. It's pretty straightforward and is designed > > to be very interoperable. The downside is that you'll need to include PEAR, > > which adds additional overhead, and the package isn't really designed for > > PHP 5.3's namespaces. You may need to alter some of the source files to get > > it to work properly with Symfony2. I haven't confirmed that last part but > > it's something to look out for. -- 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