diff --git a/include/class.osticket.php b/include/class.osticket.php
index 98979448ccf100f271caa41670046301ebf55e63..abd563839d6be9910ae4446f4aaf71694b1dc96b 100644
--- a/include/class.osticket.php
+++ b/include/class.osticket.php
@@ -144,7 +144,7 @@ class osTicket {
         $allowed = array_map('trim', explode(',', strtolower($allowedFileTypes)));
         $filename = is_array($file)?$file['name']:$file;
 
-        $ext = strtolower(preg_replace("/.*\.(.{3,4})$/", "$1", $filename));
+        $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
 
         //TODO: Check MIME type - file ext. shouldn't be solely trusted.