ZF-8064: File validation by "IsImage" broke upload process
Description
File validation by "IsImage" broke upload process. No php warning or error, no validation errors even if file type is incorrect.
Example 1: $this->addElement('file', 'file', array( 'size' => '40', 'label' => 'Seleccione un archivo de imagen que desea subir.', 'required' => true, 'description' => 'Tipo de archivos permitidos: bmp, gif, jpg, png', 'validators' => array( 'Size' => array('min' => 20000, 'max' => 1000000), 'IsImage' => array('image/bmp', 'image/gif', 'image/jpeg', 'image/pjpeg', 'image/png') ) ));
Example 2: $this->addElement('file', 'file', array( 'size' => '40', 'label' => 'Seleccione un archivo de imagen que desea subir.', 'required' => true, 'description' => 'Tipo de archivos permitidos: bmp, gif, jpg, png', 'validators' => array( 'Size' => array('min' => 20000, 'max' => 1000000), 'IsImage' ) ));
With ZF 1.9.2 everything is OK!
Comments
Posted by Thomas Weidner (thomas) on 2009-10-15T14:25:40.000+0000
When the process is broken then there must be a returned value, error message, validation message or exception. Something must be returned.
Or you have changed anything... only updated parts of the framework instead of the complete framework?
Try to call the validator standalone so you can give us something reproducable.
You could also try trunk and see if this issue exists also for the next major release.
Posted by Thomas Weidner (thomas) on 2009-10-16T00:44:29.000+0000
I just tried to reproduce, but I am not able... all works like expected. Can you give additional informations ?
Posted by Vasa Grujic (vasa) on 2009-10-16T02:51:51.000+0000
Scenario: When hint the submit button, after choosing the image file to upload, page is just refreshed. Without any feedback. In case without IsImage validation everything go smooth.
Form:
<?php
class PortraitForm extends Zend_Form { public function init() { $buttonDecorator = array('ViewHelper', array('ViewScript', array('viewScript' => 'decorators/form/button.phtml', 'placement' => false))); $hiddenDecorator = array('ViewHelper', array('ViewScript', array('viewScript' => 'decorators/form/hidden.phtml', 'placement' => false)));
}
Controller:
if ($this->_request->isPost()) {
}
ZF 1.9.3 FULL, Autoload. Development environment: Mac OS X 10.6.1 with MAMP 1.7.2
Posted by Thomas Weidner (thomas) on 2009-10-18T13:07:39.000+0000
I see no failure...
The default decorators are erased and, as described in FAQ and manual, in this case the file element is not rendered correctly. The seen behaviour can be a result.
Additionally you are using 2 different adapters... this can also lead to unexpected behaviour.
As third, when you see no failure, returned message or exception then you must have configured something wrong... Zend_File can not suppress failures or exceptions. And by erasing the decorators a notice is triggered which you don't see. Check your configuration / settings.