CI框架上传mp3等音频格式文件报错

CI框架上传mp3等音频格式文件报错: The filetype you are attempting to upload is not allowed.

而上传处理类中配置$config[‘allowed_types’] = ‘mp3|jpg|png’ ;  是有mp3格式的。 经过对 $this->upload->data();的打印输出: 

Array ( [file_name] => urpd94.jpg [file_type] => audio/octet-stream [file_path] => F:/F C/LAMP/Apache-2.2/htdocs/boob/static/uploads/u1/ [full_path] => F:/F C/LAMP/Apache-2.2/htdocs/boob/static/uploads/u1/urpd94.jpg [raw_name] => urpd94 [orig_name] => [client_name] => 3355.mp3 [file_ext] => .mp3 [file_size] => 20420 )

从上边我们可看出 file_type 的类型并不是audio/mp3 或audio/mpeg , 查看了application/config/mimes.php,看到这行

‘mp3’ => array(‘audio/mpeg’, ‘audio/mpg’, ‘audio/mpeg3’, ‘audio/mp3’), 就明白了,

需要在这里添加上这种类型:

‘mp3’ => array(‘audio/mpeg’, ‘audio/mpg’, ‘audio/mpeg3’, ‘audio/mp3’, ‘audio/octet-stream’),

新版的codeIgniter 并不会出现错误,而某个旧版会报这样的错误。

Leave a Reply

电子邮件地址不会被公开。 必填项已用*标注

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>