public function agregarproductoAction() { $form = new Application_Form_Agregarproducto(); if ($this->getRequest()->isPost()) { if ($form->isValid($this->_getAllParams())) { $model = new Application_Model_DbTable_CartaProductos(); $nombre = $form->getValue('nombre'); $descripcion = $form->getValue('descripcion'); $precio = $form->getValue('precio'); $puntos_producto = $form->getValue('puntos_producto'); $id_tipo_producto = $form->getValue('id_tipo_producto'); $estado_web = 1; $nueva_foto = $form->getValue('element'); $fecha = new Zend_Db_Expr('NOW()'); if ($nueva_foto != NULL) { $name = strtolower($nueva_foto); $upload = new Zend_File_Transfer_Adapter_Http(); $upload->setDestination(APPLICATION_PATH . '/../public/images/carta/'); $upload->addFilter('rename', array('target' => APPLICATION_PATH . '/../public/images/carta/' . $name, 'overwrite' => true)); try { $upload->receive(); } catch (Zend_File_Transfer_Exception $e) { $e->getMessage(); } } else { $name = 'default_carta.jpg'; } $model->agregarproducto($nombre, $descripcion, $precio, $name, $puntos_producto, $estado_web, $id_tipo_producto, $fecha); return $this->_redirect('/administrador/listarproductos'); } } $this->view->form = $form; }