. * */ 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 = $_GET['opc']; switch ($opc) { case 'form':return $this->formulario(); case 'importar':return $this->importarFichero(); case 'ejecutar':return "Ok"; } } 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); return $csv->cargaCSV($uploadfile); } private function formulario() { $accion = "index.php?importacion&opc=importar"; $salida = '
' . "\n"; $salida .="

Elige Archivo\n"; $salida .= ''; $salida .='


' . "\n"; $salida .=""; return $salida; } } ?>