[eluser]rogierb[/eluser]
Hello all,
I'm rewriting a 10 year old system and are now faced with fun filenames like this.is.a.old.filename.jpg
which is causing problem in the upload library.
After each part an underscore is added even if you add the 'overwrite' config.
This is due to the nature of _prep_filename() in the Uploads library. Since nowadays common practice is to use either underscores or dashes, the possibility of dots is forgotten.
I would like to use dashes or underscores but I'm not going to rename thousands of files, so i had to change a core method wich I hate.
My quick and very dirty solution is
Code:
foreach ($parts as $part)
{
if ( (! in_array(strtolower($part), $this->allowed_types) OR $this->mimes_types(strtolower($part)) === FALSE ) AND $part === $parts[count($parts) - 1])
{
if($this->overwrite == FALSE) $filename .= '.'.$part.'_';
else $filename .= '.'.$part;
}
else
{
$filename .= '.'.$part;
}
}
Am I missing something? Can this be solved without hacking the core?