simplyfy mimetype parsing of 'file' output
This commit is contained in:
parent
6cff5418a7
commit
1ef3e4c5c6
1 changed files with 3 additions and 4 deletions
|
@ -394,13 +394,12 @@ class OC_Helper {
|
||||||
// it looks like we have a 'file' command,
|
// it looks like we have a 'file' command,
|
||||||
// lets see if it does have mime support
|
// lets see if it does have mime support
|
||||||
$path=escapeshellarg($path);
|
$path=escapeshellarg($path);
|
||||||
$fp = popen("file -i -b $path 2>/dev/null", "r");
|
$fp = popen("file -b --mime-type $path 2>/dev/null", "r");
|
||||||
$reply = fgets($fp);
|
$reply = fgets($fp);
|
||||||
pclose($fp);
|
pclose($fp);
|
||||||
|
|
||||||
// we have smth like 'text/x-c++; charset=us-ascii\n'
|
//trim the newline
|
||||||
// and need to eliminate everything starting with semicolon including trailing LF
|
$mimeType = trim($reply);
|
||||||
$mimeType = preg_replace('/;.*/ms', '', trim($reply));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return $mimeType;
|
return $mimeType;
|
||||||
|
|
Loading…
Reference in a new issue