Zend_Form - could not find the mimetype of the file 'foto.jpg'

I have a Zend_Form with a file like:

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

And when I use localhost, the image loads successfully. But when I switch to my hosting, a validation error is displayed for the image field. The mimetic of the file 'foto.jpg' could not be detected. What could be the reason for this?

+6
upload zend-framework zend-form
source share
3 answers

The same thing happened to me, it was crazy, more than 2 hours, trying to understand what happened, here's how to fix it:

install the fileinfo extension in linux:

pecl install fileinfo

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

extension = fileinfo.so

restart your apache and you're done!

* If you are using FreeBSD, you must do this:

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

+11
source share

If you use XAMPP and localhost, just open the php.ini file and uncomment:

extension = php_fileinfo.dll

+5
source share

From the comments in the ZF Reference Guide :

In order to get IsImage to work (and possibly all other mime-related validators) on Zend Server on win32, I had to replace "magic.mime" supplied on Zend Server ("\ etc") with the one on Apache ( "\ conf", the file is called "magic") (do not forget to restart Apache).

If it still does not work, you can try with these alternatives:

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

or

  • $element->addValidator('Extension', false, 'jpg');
+3
source share

All Articles