fix getMimetype()

This commit is contained in:
Uwe Steinmann 2022-11-15 16:15:24 +01:00
parent 08d10d2cc0
commit 83770f7521

View File

@ -407,20 +407,20 @@ function getFilenameByDocname($content) { /* {{{ */
* @return string mimetype
*/
function getMimeType($filename) { /* {{{ */
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mimetype = finfo_file($finfo, $filename);
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mimetype = finfo_file($finfo, $filename);
switch($mimetype) {
case 'application/octet-stream':
case 'text/plain':
$lastDotIndex = strrpos($filename, ".");
if($lastDotIndex === false) $fileType = ".";
else $fileType = substr($name, $lastDotIndex);
if($fileType == '.md')
$mimetype = 'text/markdown';
break;
}
return $mimetype;
switch($mimetype) {
case 'application/octet-stream':
case 'text/plain':
$lastDotIndex = strrpos($filename, ".");
if($lastDotIndex === false) $fileType = ".";
else $fileType = substr($filename, $lastDotIndex);
if($fileType == '.md')
$mimetype = 'text/markdown';
break;
}
return $mimetype;
} /* }}} */
function getLogger($prefix='', $mask=PEAR_LOG_INFO) { /* {{{ */