只是一个关于 Laravels 验证器的查询。我网站的用户上传的文件有时可能会超过 100MB。
我看过:http://laravel.com/docs/4.2/validation
我的 Controller 代码如下:
$rules = array(
'file' => 'max:102400'
);
102400 是否等于 100MB,我觉得文档对此不够清楚?
最佳答案
如文档中所述:
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
所以我们使用尺寸规则:
size:value
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 是千字节。
是的,那是 100 MB。
关于php - Laravel 4 - 验证器 - 文件大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29767234/