PHP Getting file extension returning .file

When i use this function to get the file extension:
function getExtension($file){
$fileName = $_FILES[$file]['name'];
$extension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
return $extension;
It just returns .file even though the file i submitted in the form was .pdf
Any suggestion to solve this?
Answer
Solution:
This piece of code will return the uploaded file extension.
function getExtension($file)
{
$fileName = $_FILES[$file]['name'];
$fileArr = explode(".", $fileName);
return end($fileArr);
}
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: the metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.