Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php get extension from file from form submit

function get_mime($file) {
  if (function_exists("finfo_file")) {
    $finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
    $mime = finfo_file($finfo, $file);
    finfo_close($finfo);
    return $mime;
  } else if (function_exists("mime_content_type")) {
    return mime_content_type($file);
  } else if (!stristr(ini_get("disable_functions"), "shell_exec")) {
    // http://stackoverflow.com/a/134930/1593459
    $file = escapeshellarg($file);
    $mime = shell_exec("file -bi " . $file);
    return $mime;
  } else {
    return false;
  }
}
//pass the file name as
echo(get_mime($_FILES['file_name']['tmp_name']));
Comment

PREVIOUS NEXT
Code Example
Php :: oci_execute(): ORA-01810: format code appears twice in 
Php :: yii2 arraydataprovider 
Php :: php parse url get path 
Php :: php pass by reference 
Php :: laravel maintenance mode 
Php :: composer cache clean 
Php :: twig ternary 
Php :: laravel return data from model to another controller 
Php :: laravel blade route redirect back 
Php :: get localstorage value in php 
Php :: laravel array remove key 
Php :: how to take last entry in database in laravel Method ONe 
Php :: php foreach mysql result 
Php :: how to create shortcode 
Php :: mt_rand 
Php :: wordpress remove user roles 
Php :: php to int 
Php :: composer autoload psr-4 
Php :: is users logged in laravel blade 
Php :: format time laravel 
Php :: loop index foreach laravel 
Php :: laravel current date in migration 
Php :: Array and string offset access syntax with curly braces is deprecated in tcpdf.php 
Php :: php 8 attributes 
Php :: php session time out default 
Php :: laravel date between 
Php :: how to change laravel port 
Php :: max. post size 
Php :: php get current time and date 
Php :: laravel assign class dynamically if condition true 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =