Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

MimeType validator doesn't work for multiple files. #170

Open
gavinlimely opened this issue Jun 9, 2017 · 4 comments · Fixed by #180
Open

MimeType validator doesn't work for multiple files. #170

gavinlimely opened this issue Jun 9, 2017 · 4 comments · Fixed by #180

Comments

@gavinlimely
Copy link

gavinlimely commented Jun 9, 2017

Hi,

The IsImage validator doesn't work with html5 file inputs that have the multiple attribute assigned.

It validates the first file file, then gives the error :

Warning: finfo_file(): 557 is not a valid file_info resource in vendor/zendframework/zend-validator/src/File/MimeType.php on line 387

Warning: finfo_close(): 557 is not a valid file_info resource in vendor/zendframework/zend-validator/src/File/MimeType.php on line 388

Ideally, the behaviour is that it won't pass validation unless all of the files are images?

Thanks

@froschdesign
Copy link
Member

Ideally, the behaviour is that it won't pass validation unless all of the files are images?

A validator validates always one value.

But you can combine the Callback and the IsImage validator. Loop over the value and check every file.

@gavinlimely
Copy link
Author

Ok thank you for the quick response. It does seem like a work around though, seen as the file validators are built to work with the $_FILES array?

@froschdesign
Copy link
Member

froschdesign commented Jun 12, 2017

@gavinlimely

the file validators are built to work with the $_FILES array?

No, not the entire $_FILES array. Only the format (tmp_name and name) and for each only one value.
(You can use the validators also for files that have not been uploaded.)

My suggestion: an equivalent for multiple files like the Explode validator.

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-validator; a new issue has been opened at laminas/laminas-validator#19.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants