PHP Gets the MIME type type, FileInfo extension

Source: Internet
Author: User

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 into later.

Software Preparation:

php:php-5.2.14
Fileinfo:fileinfo-1.0.4.tgz
File:file-5.20.tar.gz

1. File Installation

wget FTP://ftp.astron.com/pub/file/file-5.15.tar.gztarfile-5.20 . Tar  File-5.20/ . /configure--prefix=/usr/local/services/File-5.20make make   Install

2. FileInfo Extended Compilation Installation

wgethttp//pecl.php.net/get/fileinfo-1.0.4.tgzTarZXF fileinfo-1.0.4. TGZCD Fileinfo-1.0.4//usr/local/php/bin/phpize./configure--with-php-config=/usr/local/php/bin/php-config--with-fileinfo=/usr/local/services/file-5.20/ Make#拷贝fileinfo. So to PHP.ini defined in Extension_dirCPfileinfo.so/usr/local/php/extensions/#修改php. INIEcho "extension=fileinfo.so">>/usr/local/php/lib/php.ini

3. Verification

grep Fileinfofileinfo

Note:
1, install the software attention to see./configure--help which indicates the dependency of the library or header file
2. Extended porting, view dependencies, porting need to be aware of: libmagic.so.1 dependency

Ldd/usr/local/php/extensions/fileinfo.so
Linux-vdso.so.1 = (0x00007fff9b7ff000)
Libmagic.so.1 =/usr/local/lib/libmagic.so.1 (0x00007f8493582000)
libc.so.6 =/lib64/libc.so.6 (0x00007f8493342000)
Libz.so.1 =/lib64/libz.so.1 (0x00007f849322d000)
/lib64/ld-linux-x86-64.so.2 (0x00007f84937a4000)

PHP Gets the MIME type type, FileInfo extension

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.