Zend_Form - 无法检测到文件“foto.jpg"的 mimetype [英] Zend_Form - The mimetype of file 'foto.jpg' could not be detected

查看:27
本文介绍了Zend_Form - 无法检测到文件“foto.jpg"的 mimetype的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Zend_Form 文件元素如下:

I have a Zend_Form with file element like this:

->addElement('file', 'image', array(
        'required' => false,
        'label' => 'Venue Image',
        'validators' => array(
            array('IsImage', false),
            array('Size', false, '2097152'),
            array('Upload', false),
        ),
    ))

当我使用 localhost 时,图像已成功上传.但是当我转移到我的主机时,图像字段显示验证错误.无法检测到文件foto.jpg"的 mimetype.这可能是什么原因?

And when I'm using localhost the image is uploaded successfully. But when I move to my hosting the validation error shows for image field. The mimetype of file 'foto.jpg' could not be detected. What can be the reason of this?

推荐答案

同样的事情发生在我身上,这太疯狂了,超过 2 个小时试图找出问题所在,以下是解决方法:

same thing happened to me, this was crazy stuff, more than 2 hours trying to figure out what's wrong, here is how to fix it:

在 linux 上安装 fileinfo 扩展:

install fileinfo extension on linux:

pecl 安装文件信息

pecl install fileinfo

那么你需要在你的php.ini中添加这一行:

then you need to add to your php.ini this line:

extension=fileinfo.so

extension=fileinfo.so

重启你的 apache 就大功告成了!

restart your apache and you are done!

*如果您的服务器是 freeBSD,您必须这样做:

*if you server is freeBSD you have to do this:

cd/usr/ports/sysutils/pecl-fileinfo/进行安装

cd /usr/ports/sysutils/pecl-fileinfo/ make install

这篇关于Zend_Form - 无法检测到文件“foto.jpg"的 mimetype的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆