. * */ class Importacion { private $bdd; public function __construct($baseDatos, $registrado) { if (!$registrado) { return 'Debe registrarse para acceder a este apartado'; } $this->bdd = $baseDatos; } public function ejecuta() { $opc = ''; if (isset($_GET['opc'])) { $opc = $_GET['opc']; } switch ($opc) { case 'form':return $this->formulario(); case 'importar':return $this->importarFichero(); case 'ejecutar':return $this->ejecutaFichero(); default: return "Importacion: No entiendo qué me has pedido."; } } private function importarFichero() { $uploadfile = "tmp/" . basename($_FILES['fichero']['name']); if (!move_uploaded_file($_FILES['fichero']['tmp_name'], $uploadfile)) { die('No se pudo subir el fichero ' . $_FILES['userfile']['tmp_name']); } $csv = new Csv($this->bdd); $csv->cargaCSV($uploadfile); return $csv->resumen(); } private function formulario() { $accion = "index.php?importacion&opc=importar"; $salida = '