From 9d91118e68e3ad84ce582c98a4290e5632a63b69 Mon Sep 17 00:00:00 2001 From: Epagris Date: Thu, 12 Sep 2024 08:39:17 +0200 Subject: [PATCH] - determining MIME-type fixed, works across all platforms --- interface.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/interface.php b/interface.php index 7dfdd8d..38eeec6 100644 --- a/interface.php +++ b/interface.php @@ -243,9 +243,12 @@ switch ($action) { if (isset($_FILES["game_file"])) { // decide weather it's a package or a plain table $file = $_FILES["game_file"]; - $file_type = $file["type"]; $challenge_import_status = []; - if ($file_type === "application/zip") { // a package was uploaded + + // determine MIME type + $file_type = strtolower(pathinfo($file["name"], PATHINFO_EXTENSION)); + + if ($file_type === "zip") { // a package was uploaded $zip = new ZipArchive; if ($zip->open($file["tmp_name"])) { @@ -267,7 +270,7 @@ switch ($action) { $challenge_import_status = import_challenges_from_csv($csv_files[0], $gameid); } } - } else if ($file_type === "text/csv") { // a plain table was uploaded + } else if ($file_type === "csv") { // a plain table was uploaded $challenge_import_status = import_challenges_from_csv($file["tmp_name"], $gameid); } $result = json_encode($challenge_import_status);