From 1e74da235f7739e3d9b5e1f84cda6313499cefa1 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 15 Dec 2010 10:45:06 +0000 Subject: Upload library file_name can now be set without an extension, the extension will be taken from the uploaded file instead of the given name. --- system/libraries/Upload.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'system/libraries/Upload.php') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 4ccbdde90..b0e1f4c6c 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -212,7 +212,18 @@ class CI_Upload { if ($this->_file_name_override != '') { $this->file_name = $this->_prep_filename($this->_file_name_override); - $this->file_ext = $this->get_extension($this->file_name); + + // If no extension was provided in the file_name config item, use the uploaded one + if(strpos($this->_file_name_override, '.') === FALSE) + { + $this->file_name .= $this->file_ext; + } + + // An extension was provided, lets have it! + else + { + $this->file_ext = $this->get_extension($this->_file_name_override); + } if ( ! $this->is_allowed_filetype(TRUE)) { -- cgit v1.2.3-24-g4f1b From 14287f3e81d4d717ff49e640d799c579e593f0c0 Mon Sep 17 00:00:00 2001 From: Pascal Kriete Date: Mon, 14 Feb 2011 13:39:34 -0500 Subject: Whitespace cleanup in libraries/ --- system/libraries/Upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Upload.php') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 8f84ffd7e..c8c42d885 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -214,7 +214,7 @@ class CI_Upload { $this->file_name = $this->_prep_filename($this->_file_name_override); // If no extension was provided in the file_name config item, use the uploaded one - if(strpos($this->_file_name_override, '.') === FALSE) + if (strpos($this->_file_name_override, '.') === FALSE) { $this->file_name .= $this->file_ext; } -- cgit v1.2.3-24-g4f1b