hi, i need upload file with symfony but without rename this.

i try  this in my forms

 public function configure()
  {
    unset($this['creado'], $this['actualizado']);

    $this->setWidgets(array(
      'id_archivo'  => new sfWidgetFormInputHidden(),
      'nombre'      => new sfWidgetFormInputFile(),
      'estatus_id'  => new sfWidgetFormDoctrineChoice(array('model' =>
'CfeEstatus', 'add_empty' => false)),
      'usuario_id'  => new sfWidgetFormDoctrineChoice(array('model' =>
'CfeUsuario', 'add_empty' => false)),
      'imprenta_id' => new sfWidgetFormDoctrineChoice(array('model' =>
'CfeImprenta', 'add_empty' => false)),
    ));

    $this->setValidators(array(
      'id_archivo'  => new sfValidatorDoctrineChoice(array('model' =>
'CfeArchivo', 'column' => 'id_archivo', 'required' => false)),
      'nombre'          => new sfValidatorFile(),
      'estatus_id'  => new sfValidatorDoctrineChoice(array('model' =>
'CfeEstatus')),
      'usuario_id'  => new sfValidatorDoctrineChoice(array('model' =>
'CfeUsuario')),
      'imprenta_id' => new sfValidatorDoctrineChoice(array('model' =>
'CfeImprenta')),
    ));
    $this->widgetSchema->setNameFormat('cfe_archivo[%s]');
  }

and my actions

 protected function processForm(sfWebRequest $request, sfForm $form)
  {
    $form->bind($request->getParameter($form->getName()),
$request->getFiles($form->getName()));

    if ($form->isValid())
    {
      $file = $form->getValue('nombre');
      $filename =
sha1($file->getOriginalName()).$file->getExtension($file->getOriginalExtension());
      $file->save(sfConfig::get('sf_upload_dir').'/'.$filename);

        $cfe_archivo = $form->save();

      $this->redirect('recibos/edit?id_archivo='.$cfe_archivo->getIdArchivo());
    }
  }

and this the Error.

Validation failed in class CfeArchivo

1 field had validation error:

* 1 validator failed on nombre (type)


have a Idea??

thanks

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to