From a8f7a435d2f4f064f9937d7c41f5654236f002d1 Mon Sep 17 00:00:00 2001 From: Eliot Whalan Date: Mon, 20 Jun 2016 12:52:03 +1000 Subject: Rework mime type blocking --- php/upload.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'php/upload.php') diff --git a/php/upload.php b/php/upload.php index 118552e..6ee85ad 100644 --- a/php/upload.php +++ b/php/upload.php @@ -74,6 +74,8 @@ function generateName($file) function uploadFile($file) { global $db; + global $WHITELIST_MIME; + global $FILTER_MIME; // Handle file errors if ($file->error) { @@ -81,12 +83,15 @@ function uploadFile($file) } // Check if mime type is blocked - if (!in_array(mime_content_type($file), $FILTER_MIME)) { - throw new UploadException(UPLOAD_ERR_EXTENSION); + if (!empty($FILTER_MIME)) { + if (in_array($file->mime, $FILTER_MIME)) { + throw new UploadException(UPLOAD_ERR_EXTENSION); + } } - if WHITELIST == true { - if (!in_array(mime_content_type($file), $WHITELIST_MIME)) { + if (!empty($WHITELIST_MIME)) { + if (!in_array($file->mime, $WHITELIST_MIME)) { throw new UploadException(UPLOAD_ERR_EXTENSION); + } } -- cgit v1.2.3