summaryrefslogtreecommitdiffstats
path: root/system/libraries/Upload.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-08-27 13:56:31 +0200
committerAndrey Andreev <narf@devilix.net>2014-08-27 13:56:31 +0200
commitf38c9c29e32e86d453c820bdc13abdd9c2a1a765 (patch)
tree5c58e3b7d219e01a6965accec154b9a248ab3b9a /system/libraries/Upload.php
parentfc4db348999fe9cc8d568eeba7602a11d449e2b8 (diff)
Close #3205
Diffstat (limited to 'system/libraries/Upload.php')
-rw-r--r--system/libraries/Upload.php22
1 files changed, 4 insertions, 18 deletions
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 7946111cc..49c69a32c 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -1158,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;
}
// --------------------------------------------------------------------