summaryrefslogtreecommitdiffstats
path: root/system/libraries/Upload.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-10-05 23:04:19 +0200
committerAndrey Andreev <narf@devilix.net>2014-10-05 23:04:19 +0200
commit4a485a73d64a8bebc7625aabc5fdc361d5e7dc56 (patch)
treecb18690c4de1c6ca008227260f9dd0cd2b9279d2 /system/libraries/Upload.php
parent39ec29585b7cdca7edc1a0757c913a13a2ee4f85 (diff)
parentd444d445ed0458a352ecb9ff79ffd158677ee805 (diff)
Merge branch 'develop' into feature/session
Diffstat (limited to 'system/libraries/Upload.php')
-rw-r--r--system/libraries/Upload.php47
1 files changed, 18 insertions, 29 deletions
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 75fc0624f..49c69a32c 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -327,23 +327,26 @@ class CI_Upload {
$this->$key = $defaults[$key];
}
}
-
- return $this;
+
}
-
- foreach ($config as $key => &$value)
+ else
{
- if ($key[0] !== '_' && $reflection->hasProperty($key))
+
+ foreach ($config as $key => &$value)
{
- if ($reflection->hasMethod('set_'.$key))
- {
- $this->{'set_'.$key}($value);
- }
- else
+ if ($key[0] !== '_' && $reflection->hasProperty($key))
{
- $this->$key = $value;
+ if ($reflection->hasMethod('set_'.$key))
+ {
+ $this->{'set_'.$key}($value);
+ }
+ else
+ {
+ $this->$key = $value;
+ }
}
}
+
}
// if a file_name was provided in the config, use it instead of the user input
@@ -1155,28 +1158,14 @@ class CI_Upload {
*/
protected function _prep_filename($filename)
{
- if ($this->mod_mime_fix === FALSE OR $this->allowed_types === '*' OR strpos($filename, '.') === FALSE)
+ if ($this->mod_mime_fix === FALSE OR $this->allowed_types === '*' OR ($ext_pos = strrpos($filename, '.')) === FALSE)
{
return $filename;
}
- $parts = explode('.', $filename);
- $ext = array_pop($parts);
- $filename = array_shift($parts);
-
- foreach ($parts as $part)
- {
- if ( ! in_array(strtolower($part), $this->allowed_types) OR ! isset($this->_mimes[strtolower($part)]))
- {
- $filename .= '.'.$part.'_';
- }
- else
- {
- $filename .= '.'.$part;
- }
- }
-
- return $filename.'.'.$ext;
+ $ext = substr($filename, $ext_pos);
+ $filename = substr($filename, 0, $ext_pos);
+ return str_replace('.', '_', $filename).$ext;
}
// --------------------------------------------------------------------