Hi,
Can anyone show a working example of how to validate multiple files? In my code, validation works if a single file is uploaded; but not when more than 1 is uploaded.
For example: I only allow jpg, gif, and png. I try to upload an .ini file and the validation works. If I try to upload a jpg and an .ini file, the validation doesn’t trigger an error.
Model:
public $images;
// Rules
array('images', 'file', 'types'=>'jpg, gif, png', 'allowEmpty' => true,),
Controller:
$model->images = CUploadedFile::getInstances($model, "[$i]images");
View:
<?php echo CHtml::activeFileField($model, 'images', array('multiple' => true)); ?>
In the view, I have tried setting the name to include the double square brackets but this doesn’t work either.
Ex: <?php echo CHtml::activeFileField($model, ‘images’, array(‘name’ => ‘images[]’, ‘multiple’ => true)); ?>
Any ideas?