An alternative way of getting the file extension of a user uploaded image in PHP?

344 Views Asked by At

I'm trying to get a file extension of a user uploaded image, I have learnt that several approaches exist to achieve this goal. I think this is currently the conversational way of getting the file extension:

$ext = pathinfo($_FILES["userfile"]["name"], PATHINFO_EXTENSION);

However, I find the following method to be more intuitive and memorable:

list(,$ext) = explode("/", $_FILES["userfile"]["type"]);

What are the drawbacks of taking the latter approach?

0

There are 0 best solutions below