- determining MIME-type fixed, works across all platforms

This commit is contained in:
Wiesner András 2024-09-12 08:39:17 +02:00
parent 0980abfdd4
commit 9d91118e68

View File

@ -243,9 +243,12 @@ switch ($action) {
if (isset($_FILES["game_file"])) { if (isset($_FILES["game_file"])) {
// decide weather it's a package or a plain table // decide weather it's a package or a plain table
$file = $_FILES["game_file"]; $file = $_FILES["game_file"];
$file_type = $file["type"];
$challenge_import_status = []; $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; $zip = new ZipArchive;
if ($zip->open($file["tmp_name"])) { if ($zip->open($file["tmp_name"])) {
@ -267,7 +270,7 @@ switch ($action) {
$challenge_import_status = import_challenges_from_csv($csv_files[0], $gameid); $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); $challenge_import_status = import_challenges_from_csv($file["tmp_name"], $gameid);
} }
$result = json_encode($challenge_import_status); $result = json_encode($challenge_import_status);