mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-03-12 08:55:54 +00:00
add function get_extension()
returns file extension by mimetype Conflicts: inc/inc.Utils.php
This commit is contained in:
parent
5afc6ef54f
commit
c8fcd1cebc
|
@ -503,4 +503,45 @@ function decryptData($key, $value){
|
|||
return trim($decrypttext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return file extension for a give mimetype
|
||||
*
|
||||
* @param string $mimetype Mime-Type
|
||||
* @return string file extension including leading dot
|
||||
*/
|
||||
function get_extension($mimetype) { /* {{{ */
|
||||
if(empty($mimetype)) return false;
|
||||
switch($mimetype) {
|
||||
case 'image/bmp': return '.bmp';
|
||||
case 'image/cis-cod': return '.cod';
|
||||
case 'image/gif': return '.gif';
|
||||
case 'image/ief': return '.ief';
|
||||
case 'image/jpeg': return '.jpg';
|
||||
case 'image/pipeg': return '.jfif';
|
||||
case 'image/tiff': return '.tif';
|
||||
case 'image/x-cmu-raster': return '.ras';
|
||||
case 'image/x-cmx': return '.cmx';
|
||||
case 'image/x-icon': return '.ico';
|
||||
case 'image/x-portable-anymap': return '.pnm';
|
||||
case 'image/x-portable-bitmap': return '.pbm';
|
||||
case 'image/x-portable-graymap': return '.pgm';
|
||||
case 'image/x-portable-pixmap': return '.ppm';
|
||||
case 'image/x-rgb': return '.rgb';
|
||||
case 'image/x-xbitmap': return '.xbm';
|
||||
case 'image/x-xpixmap': return '.xpm';
|
||||
case 'image/x-xwindowdump': return '.xwd';
|
||||
case 'image/png': return '.png';
|
||||
case 'image/x-jps': return '.jps';
|
||||
case 'image/x-freehand': return '.fh';
|
||||
case 'image/svg+xml': return '.svg';
|
||||
case 'application/zip': return '.zip';
|
||||
case 'application/x-rar': return '.rar';
|
||||
case 'application/pdf': return '.pdf';
|
||||
case 'application/postscript': return '.ps';
|
||||
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': return '.docx';
|
||||
case 'text/plain': return '.txt';
|
||||
case 'text/csv': return '.csv';
|
||||
default: return false;
|
||||
}
|
||||
} /* }}} */
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue
Block a user