Laravel 4-验证程序-文件大小 [英] Laravel 4 - Validator - File Size
问题描述
只是有关Laravels验证器的查询.我网站的用户上载文件的时间可能会达到100MB左右.
Just a query about Laravels' validator. Users' of my site are going to be uploading files at times that are possibly going to be around the 100MB Mark.
我查看了: http://laravel.com/docs/4.2/validation
我的控制器代码如下:
$rules = array(
'file' => 'max:102400'
);
102400相当于100MB,我觉得文档不够清晰吗?
Is 102400 the equivalent of 100MB, I don't feel the docs are clear enough on this?
推荐答案
如文档中所述:
max:value
max:value
正在验证的字段必须小于或等于最大值 价值. 字符串,数字和文件的评估方式相同 作为大小规则
The field under validation must be less than or equal to a maximum value. Strings, numerics, and files are evaluated in the same fashion as the size rule
因此,我们转到大小"规则:
So we go to the Size rule:
大小:值
正在验证的字段必须具有与给定值匹配的大小. 对于字符串数据,值对应于字符数.为了 数字数据,值对应于给定的整数值. 对于文件, 大小对应于以千字节为单位的文件大小..
The field under validation must have a size matching the given value. For string data, value corresponds to the number of characters. For numeric data, value corresponds to a given integer value. For files, size corresponds to the file size in kilobytes.
所以102400是千字节.
So the 102400 is Kilobytes.
是的100 MB.
这篇关于Laravel 4-验证程序-文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!