How to get the file extension in PHP?
This will work as well:
$array = explode('.', $_FILES['image']['name']);
$extension = end($array);
No need to use string functions. You can use something that's actually designed for what you want: pathinfo()
:
$path = $_FILES['image']['name'];
$ext = pathinfo($path, PATHINFO_EXTENSION);