[eluser]Unknown[/eluser]
Hi Guys,
I've found an issue in upload class. There is a loop, that checks if the filename exists, and if it is, then it checks once again with a number at the end of filename. That is quite ok, but only, if the filename doesn't contain numbers allready, because if the filename contains numbers that mean something, then adding a number at the end is wrong, for example:
file
fiat500.jpg exists, so upload class will add 1 at the end, and saves file with name
fiat5001.jpg. It should add a underscore before number, to check if
fiat500_1.jpg exists and so on.
I've attached improved class, and this is what is changed:
Code:
$new_filename = '';
for ($i = 1; $i < 100; $i++)
{
if ( ! file_exists($path.$filename.'_'.$i.$this->file_ext))
{
$new_filename = $filename.'_'.$i.$this->file_ext;
break;
}
}
Cheers