Jump to content

[SOLVED] Function to get image type?


Andy-H

Recommended Posts

You could work backwards.

 

Once you have the URL, use substr to return the last 4 characters

 

$image = "example.jpg";
$ext = substr($image, -4);
if($ext == ".jpg") echo "This is a jpg";
else echo "This is a different image type";

 

This will only work if you know what extensions you are looking for

Besides, I could just use:

 


$file = "http://www.example.com/pic.jpeg";

$file = explode(".", $file);
$index = count($file) - 1;

$extention = $file[$index];

 

Yea, there's a few options, but you're $type['mime'] seems like the ebst option for you

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.