Zend_Form - The mimetype of file 'foto.jpg' could not be detected
Asked Answered
A

3

6

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),
        ),
    ))

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?

Abcoulomb answered 26/3, 2010 at 19:50 Comment(1)
I'd guess that you need mime extension and hosting doesn't have it installed ;)Bosporus
V
12

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:

install fileinfo extension on linux:

pecl install fileinfo

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

extension=fileinfo.so

restart your apache and you are done!

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

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

Vanthe answered 4/4, 2010 at 14:43 Comment(0)
S
5

If you are using XAMPP and localhost just open your php.ini file and uncomment:

extension=php_fileinfo.dll

Sternick answered 6/11, 2012 at 9:51 Comment(0)
B
3

From the comments in the ZF Reference Guide:

In order to make IsImage working (and maybe all other mime related validators) on Zend Server on win32 I had to replace "magic.mime" supplied on Zend Server ("\etc") by the one on Apache ("\conf" , file is called "magic") (don't forget to restart Apache).

If it still doesn't work then you could try with these alternatives:

  • $element->addValidator('Mimetype', false, 'image/jpg');

or

  • $element->addValidator('Extension', false, 'jpg');
Bacchant answered 26/3, 2010 at 23:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.