satishgaudo.com

Understanding technology

Function to get the mime type of the file

/**
* getFileMimeType
* returns the mime type of the file
* @param string $sFilePath File path
* @return string mime type of the file
* @access public
*/
public function getFileMimeType($sFilePath)
{
exec('/usr/bin/file -i -b ' . realpath($sFilePath), $aOutput);
$sType = $aOutput[0];
$aMimeTypeDet = explode(';', $sType);
return trim($aMimeTypeDet[0]);
}
Bookmark and Share
Categories: PHP
Sdanektir at 02:15 on 7 August 2009

OMG…totally!

Vivalkakira at 21:37 on 7 August 2009

Amazing news, thank you!

*