Zubrag.com
June 17, 2019, 05:13:22 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: mime type detection on php  (Read 7972 times)
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« on: January 26, 2007, 04:12:01 PM »

  $mtype = '';

  // magic_mime module installed?
  if (function_exists('mime_content_type')) {
    $mtype = mime_content_type($file_path);
  }
  // fileinfo module installed?
  else if (function_exists('finfo_file')) {
    $finfo = finfo_open(FILEINFO_MIME); // return mime type
    $mtype = finfo_file($finfo, $file_path);
    finfo_close($finfo); 
  }

Note: this code tries to use magic_mime or fileinfo module for mime type detection. Some hosters does not have these modules installed.

Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC