What's the best way/practice to get the extension of a uploaded file in PHP
- by Roland
I have a form that allow users to upload files, I however need to get the file extension, which I am able to get, but not sure if I'm using the most effective solution
I can get it using the following ways
$fileInfo = pathinfo($_FILES['File']['name']);
echo $fileInfo['extension'];
$ext = end(explode('.',$_FILES['File']['name']));
echo $ext;
Which method is the best to use or are there even better solutions that would get the extension?