현재 위치: > 함수 카테고리 모음> mime_content_type

mime_content_type

파일의 MIME 컨텐츠 유형을 감지하십시오
이름:mime_content_type
분류:파일 정보 fileInfo
사용 언어:php
한 줄 설명:지정된 파일의 마임 유형을 반환합니다

함수 이름 : mime_content_type ()

해당 버전 : PHP 4> = 4.3.0, PHP 5, PHP 7

함수 설명 : MIME_CONTENT_TYPE () 함수는 지정된 파일의 MIME 유형을 반환하는 데 사용됩니다.

구문 : mime_content_type (String $ filename) : String | false

매개 변수 :

  • $ filename : 지정된 파일 경로.

반품 값 :

  • 성공하면 파일의 마임 유형이 반환됩니다.
  • 실패하면 거짓이 반환됩니다.

예:

 // 示例1:返回图片文件的MIME 类型$filename = 'path/to/image.jpg'; $mime_type = mime_content_type($filename); echo $mime_type; // 输出:image/jpeg // 示例2:返回文本文件的MIME 类型$filename = 'path/to/text.txt'; $mime_type = mime_content_type($filename); echo $mime_type; // 输出:text/plain // 示例3:返回不存在的文件的MIME 类型$filename = 'path/to/nonexistent.file'; $mime_type = mime_content_type($filename); var_dump($mime_type); // 输出:bool(false)

참고 :

  • 일부 운영 체제에서는 FileInfo 확장자를 설치하고 기능을 올바르게 사용하도록 구성해야합니다.
  • 파일의 마임 유형을 얻을 수없는 경우 함수는 "Application/Octet-stream"을 반환하여 알려지지 않은 이진 파일 유형을 나타낼 수 있습니다.
유사한 함수
인기 기사