From 0a1be8ff3f6a4ab27e271bedae2afdbce2c19299 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 31 Oct 2019 14:35:03 -0500 Subject: [PATCH] Fix mime type check to allow re-upload of downloads --- src/upload.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/upload.php b/src/upload.php index 3c756b0..0eb3f24 100644 --- a/src/upload.php +++ b/src/upload.php @@ -67,8 +67,10 @@ function checkUploads($files) //Get and check mime types (ignoring provided ones) $finfo = new finfo(FILEINFO_MIME_TYPE); - if ($finfo->file($file['tmp_name']) != "application/xml") + $mimeType = $finfo->file($file['tmp_name']); + if ($mimeType != "application/xml" && $mimeType != "text/xml") { + if (DEBUG) warn('File: ' . $file['tmp_name'] . ': Invalid MIME type ' . $mimeType); unset($files[$index]); continue; } @@ -95,7 +97,7 @@ function checkUploads($files) else echo '
' . count($files) . ' files were uploaded.
'; - if (DEBUG) debug('
Adding engine: ' . $_POST['make'] . ', ' . $_POST['code'] . ', ' . $_POST['displacement'] . ', ' . $_POST['compression'] . ', ' . $_POST['aspiration'] . '
'); + if (DEBUG) debug('Adding engine: ' . $_POST['make'] . ', ' . $_POST['code'] . ', ' . $_POST['displacement'] . ', ' . $_POST['compression'] . ', ' . $_POST['aspiration']); $engineid = $msqur->addEngine($_POST['make'], $_POST['code'], $_POST['displacement'], $_POST['compression'], $_POST['aspiration']); $fileList = $msqur->addMSQs($files, $engineid);