From 7c78f4b4f476a2820e908f4ff40a65e6660a13a6 Mon Sep 17 00:00:00 2001 From: joshuaruesweg Date: Tue, 11 May 2021 14:16:07 +0200 Subject: [PATCH] Add `getFilenameExtension` for `UploadFile` instances Closes #4007 --- .../files/lib/system/file/upload/UploadFile.class.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/wcfsetup/install/files/lib/system/file/upload/UploadFile.class.php b/wcfsetup/install/files/lib/system/file/upload/UploadFile.class.php index bc7e1e658f..15e859bd41 100644 --- a/wcfsetup/install/files/lib/system/file/upload/UploadFile.class.php +++ b/wcfsetup/install/files/lib/system/file/upload/UploadFile.class.php @@ -178,6 +178,17 @@ class UploadFile return $this->filename; } + /** + * Returns the file extension for the original filename. The returned string can be empty, if the + * original filename has no file extension. + * + * @since 5.4 + */ + public function getFilenameExtension(): string + { + return \pathinfo($this->filename, \PATHINFO_EXTENSION); + } + /** * Returns the unique file id for the file. It is used to identify the certain file. * @return string -- 2.20.1