Home  >  Article  >  Backend Development  >  10 recommended articles about the php GetFiletype() function

10 recommended articles about the php GetFiletype() function

怪我咯
怪我咯Original
2017-06-11 10:46:471453browse

Sometimes we do this imperfectly. Some people may save some files on their computer, but they change the extension so that they fall within our file type. It cannot be displayed during actual access (because the extension does not match the file content). The following php class may be able to help us. 1. PHP detection class First of all, let me explain that the above mapping relationship between file headers and file types comes from the Internet. If you have new files to check, you only need to add the mapping. If you need to know the file header information, you can open the standard file search through the tool: winhex. For example: Code: Copy the code as follows: _getFileType($filename); } } How to get the header bytecode: You can see: png file, the header is 4 bytes (you need to check the relevant information yourself for how many bytes the header mark is) OK), the corresponding is: 89504E47 If you are not very familiar with PHP's pack unpack, you can check: PHP park, unpark, ord function usage (binary stream interface application example) Calling example: Copy the code code as follows: $filename="d :

1. php detects file types through file headers Universal code classes (zip, rar, etc.

10 recommended articles about the php GetFiletype() function

Introduction:: PHP detects file types through file headers. Common code classes (zip, rar, etc.: Sometimes we are not perfect in doing this. Some people may save some files, but they modify them by The extension must be within our file type. It cannot be displayed during actual access (because the extension does not match the file content). The following PHP class may be able to help us. 1. PHP detection class first explains. The above mapping relationship between file headers and file types comes from the Internet. If you have a new file to check, you only need to add the mapping. If you need to know the file header information, you can use the tool: winhex to open the standard file search, such as: Code. : Copy

2. File extension A function that gets the file extension

Introduction: File extension: File extension A function to get the file extension: A function to get the file extension

##3. A function to get the file extension_PHP tutorial

Introduction: A function to get the file extension. A function to get the file extension? /* GetFileType usage: GetFiletype($filename) */ function GetFiletype($Filename) { if ( substr_count($Filename, .) == 0) {//Check if the file name is

4. PHP detects file type class code through file header_PHP tutorial

Introduction: PHP detects file type class codes through file headers. ?php /*Get the file type through the file name* *@author chengmo* *@copyright cnblog.com/chengmo 2010-10-19 *@version 0.1 *$filename="d:/1.png";echo cFileTypeCheck: :getFileType($filena

5. A php function to get the file extension_PHP tutorial

Introduction: A php function to get the file extension. /* GetFileType usage: GetFiletype($filename) */ function GetFiletype($Filename) { if (substr_count($Filename, ".") == 0) { // Check the file name Is there a . sign? return; // Return empty

##6.

A function to get the file extension (but the function name is called Get FILETYPE! Haha!)_PHP Tutorial

Introduction: A function to get the file extension (but the function name is called Get FILETYPE! Haha!)? /* GetFileType usage: GetFiletype($filename) */ function. GetFiletype($Filename) { if (substr_count($Filename, .) == 0) {//Check whether there is a . number in the file name. return;//Return empty

##7 .

phpGet file extension_PHP tutorial

Introduction: php gets the file extension. php gets the file extension function GetFiletype($filename){ $filer=explode(.,$filename); $count=count($filer)-1; return strtolower(..$filer[$count]); }

8. php detects file types through file headers Universal code class (zip, rar, etc.)

Introduction: Working on When using web applications, we often use the web extension to determine the type of file being stored. This is what we often use.

9. A function that gets the file extension

Introduction: A function that gets the file extension. A function to get the file extension? /* GetFileType usage: GetFiletype($filename) */ function GetFiletype($Filename) { if (substr_count($Filename, .) == 0) {// Check whether the file name is

10. PHP detects file type class codes through file headers

Introduction: PHP detects file type class codes through file headers . ?php /*Get the file type through the file name* *@author chengmo* *@copyright cnblog.com/chengmo 2010-10-19 *@version 0.1 *$filename="d:/1.png";echo cFileTypeCheck: :getFileType($filena

The above is the detailed content of 10 recommended articles about the php GetFiletype() function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn