The mime_content_type() function is an inbuilt function in PHP which is used to get the MIME content-type of a file.
Syntax:
php
Output:
php
Output:
string mime_content_type( $file )Parameters: This function accepts single parameter $file which specifies the path of the file which MIME details to be find. Return Value: This function returns the MIME content type or False on failure. Below programs illustrate the mime_content_type() function in PHP: Program 1: Original Image:
<?php
// PHP program to illustrate mime_content_type function
echo mime_content_type('gfg.png') . "</br>";
?>
image/pngProgram 2: Original Image:
<?php
// PHP program to illustrate
// mime_content_type function
// Providing and print result of different kind of files
echo mime_content_type('/home/rajvir/Desktop/gfg.png') . "</br>";
echo mime_content_type('/home/rajvir/Desktop/gfg_Article.html') . "</br>";
echo mime_content_type('/home/rajvir/Downloads/gfg.gif') . "</br>";
echo mime_content_type('/home/rajvir/Desktop/gfg_contribute.txt') . "</br>";
echo mime_content_type('/home/rajvir/Downloads/geeks.ppt') . "</br>";
echo mime_content_type('/home/rajvir/Downloads/geeks.pdf') . "</br>";
?>
image/png text/plain image/gif text/plain application/vnd.ms-powerpoint application/pdfReference: https://www.php.net/manual/en/function.mime-content-type.php