summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2010-12-15 11:45:06 +0100
committerPhil Sturgeon <email@philsturgeon.co.uk>2010-12-15 11:45:06 +0100
commit1e74da235f7739e3d9b5e1f84cda6313499cefa1 (patch)
treea205f4f2eba7529f24b8c0024b9ecef0b9e98125
parenta58ecae8e149fe8e1fa9ee3cc9c9ad23a67ab8b6 (diff)
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.
-rw-r--r--system/libraries/Upload.php13
1 files changed, 12 insertions, 1 deletions
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))
{