php – Laravel 4 – Validator – 文件大小

只是关于Laravels验证器的查询.我的网站的用户将在可能大约100MB标记的时间上传文件.

我看过了:http://laravel.com/docs/4.2/validation

我的控制器代码如下:

$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是Kilobytes.

是的,这是100 MB.

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...