Count validator checks for the number of files which are
provided. It supports the following option keys:
min: Sets the minimum number of files to transfer.
When using this option you must give the minimum number of files when calling this validator the first time; otherwise you will get an error in return.
With this option you can define the minimum number of files you expect to receive.
max: Sets the maximum number of files to transfer.
With this option you can limit the number of files which are accepted but also detect a possible attack when more files are given than defined in your form.
If you initiate this validator with a string or integer, the value will be used as
max. Or you can also use the methods
setMax() to set both
options afterwards and
getMax() to retrieve the actual set values.
Example 398. Using the Count Validator
$upload = new Zend_File_Transfer();
// Limit the amount of files to maximum 2
$upload->addValidator('Count', false, 2);
// Limit the amount of files to maximum 5 and minimum 1 file
$upload->addValidator('Count', false, array('min' =>1, 'max' => 5));
Note that this validator stores the number of checked files internally. The file which exceeds the maximum will be returned as error.