Hi,

I’m wondering if it is a good idea to move the uploaded file on Zend_Form_Element_File::getValue() call.

Because:

• If the receive() failed for what ever reason I may not want to go further like inserting the other data in the database. And Currently there is no easy way to check if receive() succeed.
• Or if a database transaction failed I will have to delete the files
• What if we want to name the file from the UID of the database record


Personally I prefer to use this pattern:

$this->db->beginTransaction();
try {

// will not call receive()
$data = $this->form->getValues(); $this->insert($data);
// will call Zend_File_Transfer_Http:: receive()
// if receive() failed throw an exception then no data is inserted
$this->saveFiles();
$this->db->commit();
} catch (Exception $ex) {
$this->db->rollBack();
}

Not calling receive() on Zend_Form_Element_File::getValue() would leave more flexibility for the developer on how he want to handle the file. What do you think?

--
Laurent Melmoux
Conseil et Solutions Web | [EMAIL PROTECTED]
2mx - Annecy, France     | http://laurent.2mx.fr/

Reply via email to