How to validation number of files

邮差的信 提交于 2019-12-12 03:40:40

问题


How to validation number of files. I find many way and read alot of topic. But i can't found this result. I found only validation files size.

'files' => 'size:2560|max:2560'

All of this only files size. How can I know number of files.


回答1:


It seems that there is no default rule for the number of files. However, you can write a custom rule for validation.

https://laravel.com/docs/5.3/validation#rule-file

Please have a look here for a sample on implementation for the same.

Limit number of files that can be uploaded




回答2:


if your files is an array max checks array length.

'files' => 'max:5' //maximum number of files: 5

'files.*' => 'max:5' //maximum size of each file: 5kb


来源:https://stackoverflow.com/questions/41328265/how-to-validation-number-of-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!