From 091ce97096d54232ab28408202f877312e0155dd Mon Sep 17 00:00:00 2001 From: Mandragorat Wandystanu Date: Wed, 30 May 2018 16:04:58 +0200 Subject: upload.php: Send 415 status code when uploaded file has forbidden MIME type. --- static/php/upload.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/static/php/upload.php b/static/php/upload.php index c8bae73..39a13d9 100644 --- a/static/php/upload.php +++ b/static/php/upload.php @@ -92,11 +92,17 @@ function uploadFile($file) if (!empty($FILTER_MIME)) { if ($FILTER_MODE == true) { //whitelist mode if (!in_array($file->mime, $FILTER_MIME)) { - throw new UploadException(UPLOAD_ERR_EXTENSION); + throw new Exception( + 'Niedozwolony format pliku', + 415 + ); // HTTP status code "415 Unsupported Media Type" } } else { // blacklist mode if (in_array($file->mime, $FILTER_MIME)) { - throw new UploadException(UPLOAD_ERR_EXTENSION); + throw new Exception( + 'Niedozwolony format pliku', + 415 + ); // HTTP status code "415 Unsupported Media Type" } } } -- cgit v1.2.3