简体   繁体   中英

Get image type from mime type in PHP

In PHP, there are two functions, image_type_to_extension and image_type_to_mime_type , however, I am looking for the oppsite. Is there something like mime_type_to_image_type so I can retrieve the type from the mime (I only have image/jpeg, or image/png, and like to eventually get the extension)?

Please note that I cannot use exif_imagetype or getimagesize because the hosting server does not allow it. The php setting allow_url_fopen is turned off for security reasons.

Thanks.

You probably can use the Client URL Library (cURL) to extract this information from the raw data of the file. You can see some examples in this related answer .

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