Actually I'm developing a simple file uploader.
In the ImageUploader.php file I define the getInputFilter function, all works unless I try to add a File\MimeType validator:
<?php
namespace Admin\Model;
use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;
use Zend\Validator\File\MimeType; //tried also with use Zend\Validator\File;
[...]
public function getInputFilter()
{
[...]
$inputFilter->add($factory->createInput(array(
'name' => 'image',
'required' => true,
'validators' => array(
array(
'name' => 'MimeType', //tried also with File\MimeType
'options' => array(
'mimeType' => array('image/jpeg'),
),
),
),
)));
[...]
}
What's the correct way to define a File\Validator\MimeType?
Thank you in advance.
Not sure which version you are using now but with Zendframework 2.4 you can now do this. Hope this helps.
Here is a sample from my project with a couple of other useful features (renaming for example):
The code however could be refactored to move the logic to some lib or model.