Improve extension gathering function 

Extension now is got from pathinfo($filename, PATHINFO_EXTENSION);

So no problems in the future with filenames containing more than 1 dot like test.img.jpg