mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-11 17:44:56 +00:00
add function get_extension()
returns file extension by mimetype
This commit is contained in:
parent
212e345cdc
commit
561b8d81ee
|
@ -442,4 +442,46 @@ function checkQuota($user) { /* {{{ */
|
|||
|
||||
return ($quota - $user->getUsedDiskSpace());
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* 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