Reputation: 1242
I am quite newbie in zend framework 2. I am not working with file uploading in a standard manner before in zend framework 2. I am in stuck to validate image file for size, extension etc in inputfilter. Here is my validation code which is not working at all.
$inputFilter->add(
array(
'name' => 'WEB_LOGO',
'required' => false,
'validators' => array(
array(
'name' => 'Zend\Validator\File\Size',
'options' => array(
'min' => 120,
'max' => 200000,
),
'name' => 'Zend\Validator\File\Extension',
'options' => array(
'extension' => 'png',
),
),
),
)
);
The zend framework 2 file uploading process seems to me more complicated. Is it wise to upload file using raw php function?
However, how can i validate image file easily in inputfilter and it will be great help for me if anyone guide me how to upload two or three file input easily in zend framework 2.
Thanks for kind attention.
Upvotes: 1
Views: 3720
Reputation: 1274
The code you have tried will only utilize the Extension
and not the Size
validator.
As @foozy
said, try this to get both working -
$inputFilter->add(
array(
'name' => 'WEB_LOGO',
'required' => false,
'validators' => array(
array(
'name' => 'Zend\Validator\File\Size',
'options' => array(
'min' => 120,
'max' => 200000,
),
),
array(
'name' => 'Zend\Validator\File\Extension',
'options' => array(
'extension' => 'png',
),
),
),
)
);
Upvotes: 2