Php accurately obtains the object MIME type
This example describes how php can accurately obtain the object MIME type. Share it with you for your reference. The specific implementation method is as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12
Mime_content_type: the MIME type of the specified object is returned,Usage: The code is as follows:Copy code Echo mime_content_type ('php.gif '). "n ";Echo mime_content_type ('test. Php '); Output:Image/gifText/plainHowever, this function will
This article mainly introduces how to obtain the mime type of a file in php. The example analyzes various common techniques for obtaining the mime type of a file in php, which is of great practical value. For more information, see
This article
: This article describes how to obtain the object mime type in php. For more information about PHP tutorials, see. Php method for obtaining the object mime type
1. use the mime_content_type method
string mime_content_type ( string $filename
how PHP Gets the file MIME type
1. Using the Mime_content_type method
String Mime_content_type (String $filename) Returns the MIME content type for a file as determined by using information f Rom the magic.mime file.
However, this method was
The example in this article describes how PHP gets file MIME types. Share to everyone for your reference. Specifically as follows:
1. Using the Mime_content_type method
String Mime_content_type (String $filename)
Returns the MIME
Background:Version php-5.3 No API to view the file's Mime_type, so you need to compile the extension fileinfo to extend the PHP API (finfo_* series functions). This issue will not exist in the official release package that php-5.3 will pull FileInfo
Introduction to Linux file commands:
This command is used to identify file types and to identify the encoding format of some files. It gets the file type by looking at the header information of the file, not as if Windows determines the file type
Using file suffixes and MIME type detectionUsually we want to strictly restrict the file type, we can simply use $_files[' myFile ' [' type '] to get the MIME type of the file and then to detect whether it is a legitimate type.
Or we can take the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.