简体   繁体   中英

check if a files mime-type matches it's extension in php

Is there any way to check that a files mime-type matches it's extension in php ?

Thanks, Adam

See here: http://www.php.net/manual/en/function.finfo-file.php . This function allows you to detect the file's mime-type.

If you have a list of known mime types with corresponding extensions, using the mime_content_type function and looking up the extension in an array is simple. There are problems, however; a comprehensive list would be large and likely become outdated fairly quickly, and sniffing mime types is generally considered a difficult problem with inaccurate solutions .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM