note 36632 added to function.imagetypes
| From: | jocke at selincite dot IHATESP4M dot com | Date: | Thu, 16 Oct 2003 18:56:29 +0000 |
| Subject: | note 36632 added to function.imagetypes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-58715@lists.php.net to get a copy of this message | ||
I wrote this function that returns an array with the supported image types
<?php
function getSupportedImageTypes() {
$aSupportedTypes = array();
$aPossibleImageTypeBits = array(
"IMG_GIF",
"IMG_JPG",
"IMG_PNG",
"IMG_WBMP"
);
foreach ($aPossibleImageTypeBits as $iIndex => $sImageTypeBits) {
$sEval = "if (";
$sEval .= "imagetypes() & " . $sImageTypeBits . "";
$sEval .= ") { return TRUE; } else { return FALSE; }";
if (eval($sEval)) {
$aSupportedTypes[] = str_replace("IMG_", "", $sImageTypeBits);
}
}
return $aSupportedTypes;
}
?>
Hope that helps someone :)
/Jocke Selin
PS, if you know of a better way that doesn't include eval(), please let me know.
----
Manual Page -- http://www.php.net/manual/en/function.imagetypes.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+36632
Delete -- http://master.php.net/manage/user-notes.php?action=delete+36632&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+36632&report=yes
Search -- http://master.php.net/manage/user-notes.php