From 7de15bc54c14ce4fa74480f3894f9aec23dbcfba Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 3 Sep 2014 23:06:02 +0200 Subject: [ticket/13031] Only use mimetype guesser guess if it helps us If we already have a mimetype and the guesser's guess is the default fallback, we should keep the already existing mimetype the browser supplied. Otherwise, platforms that might not support mimetype guessers will cause us to always have the mimetype set to application/octet-stream on images. This will prevent users from uploading images. PHPBB3-13031 --- phpBB/includes/functions_upload.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_upload.php') diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php index a0a67ccf3d..ae04fe737c 100644 --- a/phpBB/includes/functions_upload.php +++ b/phpBB/includes/functions_upload.php @@ -232,7 +232,12 @@ class filespec { if ($this->mimetype_guesser !== null) { - $this->mimetype = $this->mimetype_guesser->guess($filename); + $mimetype = $this->mimetype_guesser->guess($filename); + + if (empty($this->mimetype) || $mimetype !== 'application/octet-stream') + { + $this->mimetype = $mimetype; + } } return $this->mimetype; -- cgit v1.2.1