That's a tough question. I don't think there is a way to solve this if
you want to pass the entire $_FILES array.
A different solution would be to test the fields in each entry of
$_FILES, not the array itself. Set up a ruleset with Zend_Filter_Input
and then loop through $_FILES, validating each entry individually:
$validators = array('size' => array('Int', array('LessThan',
100000)));
$input = new Zend_Filter_Input(null, $validators);
foreach ($_FILES as $field => $filedata) {
$input->setData($filedata);
if ($input->hasInvalid()) {
echo "File upload error for field $field: ".implode(', ',
$input->getMessages())."\n";
}
}
Regards,
Bill Karwin
> -----Original Message-----
> From: Marcin Stefaniak [mailto:[EMAIL PROTECTED]
> Sent: Sunday, June 03, 2007 2:39 AM
> To: Zend Framework General
> Subject: [fw-general] Zend_Filter_Input and $_FILES
>
> I'm trying to validate file upload with Zend_Filter_Input.
> I've created my own class, which implements
> Zend_Validate_Interface, for file size validating. My
> isValid() method is simple comparing file size
> $_FILES['myfile']['size'] with assumed value. The problem is
> that Zend_Filter_Input iterates all arrays he finds in input
> array, so in my case he will make my test on all items he
> will find in $_FILES['myfile'] array -
> $_FILES['myfile']['tmp_name'], $_FILES['myfile']['name'],
> $_FILES['myfile']['type'] and so on. And I want to check only
> $_FILES['myfile']['size'] value. Is there a solution, which
> let me pass full $_FILES['myfile'] array to my validate
> class? I know I can use only validate class to make this
> test, but I'd like to use Zend_Filter_Input.
>
> --
> Marcin Stefaniak
>
>