From 35b47cd57fa55004a891cd4b1eba77178082b751 Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 15 May 2025 17:02:16 +0200 Subject: [PATCH] Added method to check file extension Signed-off-by: snipe --- app/Helpers/StorageHelper.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/Helpers/StorageHelper.php b/app/Helpers/StorageHelper.php index 47700f913a..3e0e9e2363 100644 --- a/app/Helpers/StorageHelper.php +++ b/app/Helpers/StorageHelper.php @@ -50,15 +50,26 @@ class StorageHelper 'png', ]; - // The file exists and is allowed to be displayed inline if (Storage::exists($file_with_path) && (in_array(pathinfo($file_with_path, PATHINFO_EXTENSION), $allowed_inline))) { return true; } + return false; } + public static function getFiletype($file_with_path) { + + // The file exists and is allowed to be displayed inline + if (Storage::exists($file_with_path)) { + return pathinfo($file_with_path, PATHINFO_EXTENSION); + } + + return null; + + } + /** * Decide whether to show the file inline or download it. */