Sometimes we don't do it well. Some people may have saved some files, but he has changed the extension so that it is within our file type. Cannot be displayed when a single actual visit (because the extension does not match the contents of the file). The following PHP class may be helpful to us. First, the PHP detection class is described above, the above file header and file type mapping relationship from the Internet, if you have a new file to check, only need to add the mapping. If you need to know the file header information, you can open the standard file lookup by using the tool: Winhex. such as: Code: Copy code code as follows: _getfiletype ($filename); }} How to get the first byte code: You can see: PNG file, the header is 4 bytes (the header tag is how many bytes need to check the relevant data to determine), corresponds to: 89504E47 If you are not familiar with PHP pack unpack, you can view: Php Park, Unpark, Ord function use method (binary stream Interface application instance) Call instance: Copy code code as follows: $filename = "D:
1. PHP through the file header detection file type Generic code class (Zip,rar, etc.
Introduction:: PHP through the file header detection file type Generic code class (Zip,rar, etc.: Sometimes we do this is not perfect. Some people may have saved some files, but he has changed the extension so that it is within our file type. Cannot be displayed when a single actual visit (because the extension does not match the contents of the file). The following PHP class may be helpful to us. First, the PHP detection class is described above, the above file header and file type mapping relationship from the Internet, if you have a new file to check, only need to add the mapping. If you need to know the file header information, you can open the standard file lookup by using the tool: Winhex. Example: Code: Copy
2. file extension A function that obtains the file name extension
Description: File extension: File extension A function that obtains a file name extension: A function that obtains the file extension <? /* Getfiletype usage: getfiletype ($filename) */function Getfiletype ($Filename) {if (Substr_count ($Filename, ".") = = 0) {// Check the file name for a. Number. Return
3. A function to get the file extension _php tutorial
Summary: A function that obtains the file name extension. A function that gets the file name extension? /* Getfiletype usage: getfiletype ($filename) */function Getfiletype ($Filename) {if (Substr_count ($Filename,.) = = 0) {//Check text The name of the item is
4. PHP to detect file type class code through file header _php Tutorial
Introduction: PHP detects file type class code by file header. PHP/* File type is obtained by filename * * @author chengmo* * @copyright Cnblog.com/chengmo 2010-10-19 * @version 0.1 *$ Filename= "D:/1.png"; Echo Cfiletypecheck::getfiletype ($filena
5. A php function _php tutorial to get the file name extension
Summary: A PHP function that obtains a file extension. /* Getfiletype usage: getfiletype ($filename) */function Getfiletype ($Filename) {if (Substr_count ($Filename, ".") = = 0) {// Check the file name for a. Number. Return return empty
6. A function that obtains the file name extension (but the function is called to get filetype!). Oh! ) _php Tutorial
Introduction: A function to get the file extension (though the function is called to get filetype!) Oh! )。? /* Getfiletype usage: getfiletype ($filename) */function Getfiletype ($Filename) {if (Substr_count ($Filename,.) = = 0) {//Check text Whether there is a. Number in the name of the item. return;//return NULL
7. php Get file extension _php tutorial
Summary: PHP Gets the file name extension. PHP obtains file extension function Getfiletype ($filename) {$filer =explode (., $filename); $count =count ($filer)-1; return Strtolower (.. $filer [$count]); }
8. PHP through the file header detection file type Generic code class (Zip,rar, etc.)
Summary: When doing Web applications, the file type is judged by the web extension, which we often use.
9. A function that obtains the file name extension
Summary: A function that obtains the file name extension. A function that gets the file name extension? /* Getfiletype usage: getfiletype ($filename) */function Getfiletype ($Filename) {if (Substr_count ($Filename,.) = = 0) {//Check text The name of the item is
PHP detects file type class code by file header
Introduction: PHP detects file type class code by file header. PHP/* File type is obtained by filename * * @author chengmo* * @copyright Cnblog.com/chengmo 2010-10-19 * @version 0.1 *$ Filename= "D:/1.png"; Echo Cfiletypecheck::getfiletype ($filena