note 60033 added to function.image-type-to-extension

From: Date: Fri, 23 Dec 2005 13:44:45 +0000
Subject: note 60033 added to function.image-type-to-extension
Groups: php.notes 
Request: Send a blank email to php-notes+get-100618@lists.php.net to get a copy of this message
When I was writing a script for my photo website, it was necessary to write such function, which can get the extension of uploaded file (image), so the function is: <?php function get_extension($imagetype) { if(empty($imagetype)) return false; switch($imagetype) { 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'; default: return false; } } ?> It's useful for those, who upload files on server. ---- Manual Page -- http://www.php.net/manual/en/function.image-type-to-extension.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60033 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60033&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60033&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60033&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60033&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60033&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60033&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60033&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60033&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#100618) next »