diff options
| author | Eliot Whalan <ewhal@pantsu.cat> | 2016-06-20 04:52:03 +0200 |
|---|---|---|
| committer | Eliot Whalan <ewhal@pantsu.cat> | 2016-06-20 04:52:03 +0200 |
| commit | a8f7a435d2f4f064f9937d7c41f5654236f002d1 (patch) | |
| tree | 8880f64765e0e0267ca6aab5105fe42a6e9469f2 /php/upload.php | |
| parent | 4decebe30f04fb42d6f0182b5584067a5ae28f44 (diff) | |
Rework mime type blocking
Diffstat (limited to 'php/upload.php')
| -rw-r--r-- | php/upload.php | 13 |
1 files changed, 9 insertions, 4 deletions
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); + } } |
