Ver Mensaje Individual
  #2 (permalink)  
Antiguo 14/02/2011, 14:51
Avatar de GatorV
GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Zend_File_Transfer y Zend_Form::getValues()

El problema es que por defecto al llamar getValues() Zend sube el archivo, esta explicado en el Manual:
Cita:
Per default the file will automatically be received when you call getValues() on the form. The reason behind this behaviour is, that the file itself is the value of the file element.
$form->getValues();
Note: Therefor another call of receive() after calling getValues() will not have an effect. Also creating a instance of Zend_File_Transfer will not have an effect as there no file anymore to receive.
Si lo quieres hacer de la primera es mejor que pongas el siguiente flag en true setValueDisabled(true).

Por otro lado es mejor que uses los elementos directos que te brinda Zend_Form_Element_File en lugar de usar el adapter directamente un ejemplo sencillo es algo así:
Código PHP:
Ver original
  1. if ($form->isValid() {
  2.        $aValues = $form->getValues();
  3.  
  4.        $File = $form->file_element;
  5.        $File->setDestination($path);
  6.  
  7.        $File->receive(); // Aqui es donde se sube por lo que si quieres cambiar el destino, o el nombre lo puedes hacer antes.
  8. }

Saludos.