分享php获取文件mime类型的方法。具体如下:
1.使用 mime_content_type 方法
string mime_content_type ( string $filename )
Returns the MIME content type for a file as determined by using information from the magic.mime file.
<?php
$mime_type = mime_content_type('camnpr.jpg');
codeigniter是一款轻量,便捷的MVC框架,最近的项目涉及到批量上传,于是,就是用了swfupload这个插件,虽然网上有很多关于ci与swfupload的帖子,不过,并不是很完整,所以,这里综合各家优点,经过自己实际经验,做了下整理。
问题1:获取不到文件类型?
回答: 由于SWFUPLOAD所有类型文件的MIME均为application/octet-stream,故使用Codeigniter自带的上传类无法准确获取是否为图片,根据ci官方的wiki已经给出了解答
In your view file, include the SWFUpload javascript file: