Hamza
Hamza

Reputation: 49

How to get file extension from uploaded image with no extension in filename

I'm trying to get the file extension of uploaded image with

$ext = pathinfo($_FILES[$type]['name'], PATHINFO_EXTENSION);

it's working fine for the filenames having extension in it e.g image.png, pic.jpg etc but when i remove .png/.jpg from the filename e.g image, pic, it returns nothing.

Any idea how can i get the extension to be exact?

Upvotes: 1

Views: 56

Answers (1)

Armin Šupuk
Armin Šupuk

Reputation: 817

The exif_imagetype function does exactly that.

Upvotes: 3

Related Questions