diff --git a/lib/filestorage/stored_file.php b/lib/filestorage/stored_file.php index c9367160fe6..75ab48312a2 100644 --- a/lib/filestorage/stored_file.php +++ b/lib/filestorage/stored_file.php @@ -161,7 +161,7 @@ class stored_file { throw new file_exception('storedfilecannotread', '', $pathname); } } - $mimetype = $this->fs->mimetype($pathname); + $mimetype = $this->fs->mimetype($pathname, $this->file_record->filename); $this->file_record->mimetype = $mimetype; $DB->update_record('files', $this->file_record); diff --git a/repository/upload/lib.php b/repository/upload/lib.php index fa7eaf3bef8..a307ab6228d 100644 --- a/repository/upload/lib.php +++ b/repository/upload/lib.php @@ -171,7 +171,7 @@ class repository_upload extends repository { if ($this->mimetypes != '*') { // check filetype - $filemimetype = file_storage::mimetype($_FILES[$elname]['tmp_name']); + $filemimetype = file_storage::mimetype($_FILES[$elname]['tmp_name'], $record->filename); if (!in_array($filemimetype, $this->mimetypes)) { throw new moodle_exception('invalidfiletype', 'repository', '', get_mimetype_description(array('filename' => $_FILES[$elname]['name']))); }