I'm trying to validate a cakephp file upload
The following is the input in my view
<?php echo $this->Form->input('images.', array('type' => 'file', 'multiple', 'label'=>'Upload Images to your gallery')); ?>
This is the html code I get in the browser
<input type="file" required="required" id="ProjectImages" multiple="multiple" name="data[Project][images][]" />
The following is the code in my model for validation
'images[]' => array(
'extension' => array(
'rule' => array(
'extension' => array('jpeg', 'png', 'jpg'),
'message' => 'Please supply valid images'
)
),
'size' => array(
'rule' => array('fileSize', '<=', '2MB'),
'message' => 'Image must be less than 2MB'
)
)
I've also tried to validate with 'image' as the field name but both do not work. The files are uploading correctly but the validation is not working.
Please help. Thank you
The following is the code in my model for validation 'images[]' => array(- why did you think that would work? Are there any examples doing something similar? What code is reading/handling the images form data? You need to clearly demonstrate what you're doing - know that obviously a form validation rule designed for one value won't work when it's passed data in a different format.