From bc873a3ece825fc36c45ed5bccd1e993d7af4bb6 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 18 Sep 2012 12:04:54 -0400 Subject: [PATCH] Added extension handling for file path --- airtime_mvc/application/models/StoredFile.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 6c8c5d992..e31e6fd4e 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -399,6 +399,17 @@ SQL; $this->_file->save(); } + + public function getRealFileExtension() { + $path = $this->_file->getDbFilepath(); + $path_elements = explode('.', $path); + if (count($path_elements) < 2) { + return ""; + } else { + return $path_elements[count($path_elements) - 1]; + } + } + /** * Return suitable extension. * @@ -407,9 +418,13 @@ SQL; */ public function getFileExtension() { - //return ""; // TODO : what's the point of having this function? Can we not just use // the extension from the file_path column from cc_files? + $possible_ext = $this->getRealFileExtension(); + if ($possible_ext !== "") { + return $possible_ext; + } + $mime = $this->_file->getDbMime(); if ($mime == "audio/ogg" || $mime == "application/ogg") {