根据MIME获得对应的后缀名
[!!] 注意，因为存在多个后缀对应一个MIME，所以返回的结果不一定是你要的

@param string $mime
@param bool   $all
@return array|string
498309
public static function getExtensionsFromMime($mime, $all = false)
    {
        self::initMimeTypes();

        $result = $all ? [] : '';

        foreach (self::$mimeTypes as $ext => $mimeType)
        {
            if ($mime == $mimeType)
            {
                if ($all)
                {
                    $result[] = $ext;
                }
                else
                {
                    $result = $ext;
                    break;
                }
            }
        }
        return $result;
    }
850264
private function buildFrom(Swift_Mime_Message $message)
    {
        $from = $message->getFrom();

        if (current($from)) {
            return ['email' => key($from), 'name' => current($from)];
        }

        return key($from);
    }
1031550
public function getMime()
    {
        $mimes = $this->getMimes();
        $ext = strtolower($this->getExtension());

        if (isset($mimes[ $ext ])) {
            return $mimes[ $ext ];
        }

        return false;
    }
1214285
public function mime($mime)
    {
        if (empty($mime)) return $this;
        $this->content_type = $this->expected_type = Mime::getFullMime($mime);
        if ($this->isUpload()) {
            $this->neverSerializePayload();
        }
        return $this;
    }
235636
protected function _getMatchAll($key = 0) {
		foreach ($this->_regex['match_all'] as $name => $regex) {
			if (is_array($regex)) {
				$this->_setFile($name, $regex, $key);
			} else {
				$match = $this->_filterAll($regex, $this->_html, 1, $name);
				$this->_output[$key][$name] = $match;
			}
		}
	}
120118
public static function getExtensions(array $mimesTypes, $asUpperCase = false)
    {
        if (empty($mimesTypes)) {
            return [];
        }

        $extensions = [];

        foreach ($mimesTypes as $mimeType) {
            $extension = self::getExtension($mimeType);

            /*
             * No extension for given mime type?
             * Nothing to do
             */
            if (empty($extension)) {
                continue;
            }

            if ($asUpperCase) {
                if (is_array($extension)) {
                    array_walk($extension, function (&$value) {
                        $value = strtoupper($value);
                    });
                } else {
                    $extension = strtoupper($extension);
                }
            }

            $extensions[$mimeType] = $extension;
        }

        return $extensions;
    }
583281
public static function getExtensions(string $mime) : array
    {
        $extensions = [];

        foreach (static::$_types as $extension => $mimeType) {
            if ($mimeType === $mime) {
                $extensions[] = $extension;
            }
        }

        return $extensions;
    }
439746
function attach_all() {
      // Return text of body
      $mime = array();
      $mime[] = "This is a MIME message. If you are reading this text, you\r\n";
      $mime[] = "might want to consider changing to a mail reader that\r\n";
      $mime[] = "understands how to properly display MIME multipart messages.\r\n\r\n";
      $mime[] = sprintf("--Boundary-=%s\r\n", $this->boundary);

      // Insert body. If multipart/alternative, insert both html and plain.
      if (!empty($this->AltBody))
      {
          $mime[] = sprintf("Content-Type: %s; charset = \"%s\"; boundary = \"Boundary-=%s\";\r\n",
                            $this->ContentType, $this->CharSet, $this->subboundary);
          $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n\r\n", $this->Encoding);

          $mime[] = sprintf("--Boundary-=%s\r\n", $this->subboundary);
          $mime[] = sprintf("Content-Type: text/html; charset = \"%s\";\r\n", $this->CharSet);
          $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n\r\n", $this->Encoding);
          $mime[] = sprintf("%s\r\n\r\n", $this->Body);

          $mime[] = sprintf("--Boundary-=%s\r\n", $this->subboundary);
          $mime[] = sprintf("Content-Type: text/plain; charset = \"%s\";\r\n", $this->CharSet);
          $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n\r\n", $this->Encoding);
          $mime[] = sprintf("%s\r\n\r\n", $this->AltBody);

          $mime[] = sprintf("\r\n--Boundary-=%s--\r\n\r\n", $this->subboundary);
      }
      else
      {
          $mime[] = sprintf("Content-Type: %s; charset = \"%s\";\r\n", $this->ContentType, $this->CharSet);
          $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n\r\n", $this->Encoding);
          $mime[] = sprintf("%s\r\n", $this->Body);
      }

      // Add all attachments
      for($i = 0; $i < count($this->attachment); $i++)
      {
         // Check for string attachment
         $isString = $this->attachment[$i][5];
         if ($isString)
         {
            $string = $this->attachment[$i][0];
         }
         else
         {
            $path = $this->attachment[$i][0];
         }
         $filename = $this->attachment[$i][1];
         $name = $this->attachment[$i][2];
         $encoding = $this->attachment[$i][3];
         $type = $this->attachment[$i][4];
         $mime[] = sprintf("--Boundary-=%s\r\n", $this->boundary);
         $mime[] = sprintf("Content-Type: %s; ", $type);
         $mime[] = sprintf("name=\"%s\"\r\n", $name);
         $mime[] = sprintf("Content-Transfer-Encoding: %s\r\n", $encoding);
	 if (preg_match("/^img\d+/",$name))
	 {
	         $mime[] = sprintf("Content-Id: %s\r\n", "<".str_pad($i,10,"0",STR_PAD_LEFT).">");
	 }
         $mime[] = sprintf("Content-Disposition: attachment; filename=\"%s\"\r\n\r\n", $name);

         // Encode as string attachment
         if($isString)
         {
            if(!$mime[] = sprintf("%s\r\n\r\n", $this->encode_string($string, $encoding)))
               return false;
         }
         else
         {
            if(!$mime[] = sprintf("%s\r\n\r\n", $this->encode_file($path, $encoding)))
               return false;
         }
      }
      $mime[] = sprintf("\r\n--Boundary-=%s--\r\n", $this->boundary);

      return(join("", $mime));
   }
739757
public function mime()
    {
        if (!$this->exists()) {
            return false;
        }
        if (function_exists('finfo_open')) {
            $finfo = finfo_open(FILEINFO_MIME);
            $finfo = finfo_file($finfo, $this->pwd());
            if (!$finfo) {
                return false;
            }
            list($type) = explode(';', $finfo);

            return $type;
        }
        if (function_exists('mime_content_type')) {
            return mime_content_type($this->pwd());
        }

        return false;
    }
519485
public static function get_file_type_from_mime($mime) {
		$validtypes = ['application', 'audio', 'image', 'message', 'multipart', 'text', 'video'];

		if (mb_stripos($mime, '/') === false) {
			// Malformed mime type.
			return false;
		}

		$iparts = explode('/', $mime);
		if (count($iparts) !== 2) {
			// Malformed mime type.
			return false;
		}

		return (in_array($iparts[0], $validtypes, true)) ? $iparts[0] : false;
	}
1215469
public static function delete($uri, $mime = null)
    {
        return self::init(Http::DELETE)->uri($uri)->mime($mime);
    }
784340
public function set_mime_type($mime)
	{
		if (array_key_exists($mime, static::$supported_formats))
		{
			$mime = static::$supported_formats[$mime];
		}

		$this->set_header('Accept', $mime);
		return $this;
	}
760126
private static function replaceCharacters($allParam)
    {
        // replace special characters
        $allParam = str_replace(['%252C'], [','], $allParam);
        $allParam = str_replace(['%3A'], [':'], $allParam);
        return str_replace(['%7C'], ['|'], $allParam);
    }
62377
public function getMimeType($mime)
    {
        if (isset($this->mimes[$mime]))
        {
            return $this->mimes[$mime];
        }
        else
        {
            return false;
        }
    }
910588
private function get_mime_numbers(&$part)
    {
        if (strlen($part->mime_id))
            $this->mime_parts[$part->mime_id] = &$part;

        if (is_array($part->parts))
            for ($i=0; $i<count($part->parts); $i++)
                $this->get_mime_numbers($part->parts[$i]);
    }
1209643
public function archive($hashes, $mime) {
		if ($this->commandDisabled('archive')) {
			return $this->setError(elFinder::ERROR_PERM_DENIED);
		}

		$archiver = isset($this->archivers['create'][$mime])
			? $this->archivers['create'][$mime]
			: false;
			
		if (!$archiver) {
			return $this->setError(elFinder::ERROR_ARCHIVE_TYPE);
		}
		
		$files = array();
		
		foreach ($hashes as $hash) {
			if (($file = $this->file($hash)) == false) {
				return $this->error(elFinder::ERROR_FILE_NOT_FOUND, '#'+$hash);
			}
			if (!$file['read']) {
				return $this->error(elFinder::ERROR_PERM_DENIED);
			}
			$path = $this->decode($hash);
			if (!isset($dir)) {
				$dir = $this->_dirname($path);
				$stat = $this->stat($dir);
				if (!$stat['write']) {
					return $this->error(elFinder::ERROR_PERM_DENIED);
				}
			}
			
			$files[] = $this->_basename($path);
		}
		
		$name = (count($files) == 1 ? $files[0] : 'Archive').'.'.$archiver['ext'];
		$name = $this->uniqueName($dir, $name, '');
		$this->clearcache();
		return ($path = $this->_archive($dir, $files, $name, $archiver)) ? $this->stat($path) : false;
	}
1092651
static function findByName( $mimeName, $returnDefault = true )
    {
        $instance = eZMimeType::instance();
        $mimeList =& $instance->MIMEList;
        if ( isset( $mimeList[$mimeName] ) )
        {
            $mime = $mimeList[$mimeName];
            $mime['name'] = $mimeName;
            $mime['url'] = false;
            $mime['filename'] = false;
            $mime['dirpath'] = false;
            $mime['basename'] = false;
            $mime['suffix'] = false;
            if ( isset( $mime['suffixes'][0] ) )
                $mime['suffix'] = $mime['suffixes'][0];
            $mime['prefix'] = false;
            if ( isset( $mime['prefixes'][0] ) )
                $mime['prefix'] = $mime['prefixes'][0];
            $mime['is_valid'] = true;
            return $mime;
        }
        return eZMimeType::defaultValue( false, $returnDefault );
    }