I need to get the MIME type of an image, but I only have the body of the image which I\'ve got with file_get_contents. Is there a possibility to get the MIME type?<
file_get_contents
Yes, you can get it like this.
$file_info = new finfo(FILEINFO_MIME_TYPE); $mime_type = $file_info->buffer(file_get_contents($image_url)); echo $mime_type;