This article mainly introduces the solution to the problem that codeigniter cannot correctly identify the image type when uploading images. This is an uncommon problem, but it will take a long time to complete the problem, for more information about how to use codeigniter to upload images, see jpg images. However, ci is always recognized as application/octet-stream, leading to upload failure, the solution is as follows:
Enable the fileinfo extension in php. ini to obtain the correct type:
The Code is as follows:
// Windows
Extension = php_fileinfo.dll
// Linux
Extension = fileinfo. so
Note: About fileinfo
The alternative function of mime_content_type () officially recommended by PHP is the Fileinfo function. PHP 5.3.0 + supports the Fileinfo support-enabled function by default. You can use finfo_open () to determine the object MIME type without any configuration. The default LAMP environment php version installed in Centos is PHP5.2.6. If it is earlier than 5.3.0, a similar error may occur: PHP Fatal error: Call to undefined function finfo_open () in .... In the previous php version, the magic_open class needs to be loaded. The fileinfo function belongs to the PECL extension, and the fileinfo PECL extension can be enabled.