readfile($file); exit; } if (isset($_REQUEST['submit-import'])) { $file = $_FILES['import-file']["name"]; $table = $_POST['import-table']; $format = $_FILES['import-file']["type"]; echo $format; if (in_array($_FILES['import-file']["type"], array('application/vnd.ms-excel', 'text/xml', 'application/octet-stream'))) { if (move_uploaded_file($_FILES['import-file']['tmp_name'], "files/" . $_FILES['import-file']["name"])) { $import = new ImportFile("mysql", "127.0.0.1", "3306", "loft", "dake", "boromir", $table); switch ($format) { case "text/xml": $data = XmlFileFormat::retrieveArrFromFile("files" . DIRECTORY_SEPARATOR . $file); break; case "application/vnd.ms-excel": $data = CsvFileFormat::retrieveArrFromFile("files" . DIRECTORY_SEPARATOR . $file); $data = $import->convertInAssocArr($data, ImportExportBase::users_clmns); break; case "application/octet-stream": $data = JsonFileFormat::retrieveArrFromFile("files" . DIRECTORY_SEPARATOR . $file); break; } $import->writeAssosArrByTable($data); } } } } require_once "inc/header.inc.php"; require_once "inc/import-export.inc.php"; require_once "inc/footer.inc.php";