I have the following code to render the input of a zend form file
$pd_photo = new Zend_Form_Element_File('photo');
$pd_photo->setDestination(APPLICATION_PATH . '/../uploads');
$pd_photo->setRequired(false);
$pd_photo->setAllowEmpty(true);
$pd_photo->addValidator('Count', false, 1);
$pd_photo->addValidator('Size', false, 2097156672);
$pd_photo->addValidator('Extension', false, 'jpg,jpeg,png,gif,bmp');
$pd_photo->getValidator('Count')
->setMessage('You can upload only one file');
$pd_photo->getValidator('Size')
->setMessage('Your file size cannot upload file size limit of 1 MB');
$pd_photo->getValidator('Extension')
->setMessage('Invalid file extension, only valid image extensions are
(jpg, jpeg, png, gif, bmp) allowed.');
Everything works fine, but when I leave an empty file, it does not work. The zend form validator returns an empty error line message.
What is bad to do?
source
share