public function agregarAction() { $this->view->subtitle = "Agregar"; if ($this->_request->isPost()) { Zend_Loader::loadClass('Zend_Filter_StripTags'); $filter = new Zend_Filter_StripTags(); $descripcion = trim($this->_request->getPost('descripcion')); //FIXME: tiene que venir desde la configuración $ruta = realpath('.') . DIRECTORY_SEPARATOR . 'userfiles' . DIRECTORY_SEPARATOR; if (!move_uploaded_file($_FILES['archivo']['tmp_name'], $ruta . $_FILES['archivo']['name'])) { die('error al mover archivo'); } if ($descripcion) { $data = array('nombre' => $_FILES['archivo']['name'], 'descripcion' => $descripcion, 'id_sitio' => $this->session->sitio->id); $archivo = new Archivos(); $archivo->insert($data); $this->_redirect('/admin/archivos/'); return; } } $this->view->archivo = new stdClass(); $this->view->archivo->id = null; $this->view->archivo->nombre = ''; $this->view->archivo->descripcion = ''; $this->view->archivo->ruta = ''; $this->view->action = "agregar"; $this->view->buttonText = "Agregar"; $this->render(); }