Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
weierophinney opened this issue Dec 31, 2019 · 3 comments
Closed

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

weierophinney opened this issue Dec 31, 2019 · 3 comments
Assignees
Labels
Won't Fix This will not be worked on

Comments

@weierophinney
Copy link
Member

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


Originally posted by @gavinlimely at zendframework/zend-validator#170

@weierophinney
Copy link
Member Author

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.


Originally posted by @froschdesign at zendframework/zend-validator#170 (comment)

@weierophinney
Copy link
Member 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?


Originally posted by @gavinlimely at zendframework/zend-validator#170 (comment)

@weierophinney
Copy link
Member Author

@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.


Originally posted by @froschdesign at zendframework/zend-validator#170 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Won't Fix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants