Laravel 4 - Validator - File Size

Just a request for a Laravels validator. Users of my site are going to download files at times, which will probably be around the 100MB mark.

I looked at: http://laravel.com/docs/4.2/validation

My controller code looks like this:

$rules = array(
 'file' => 'max:102400'
);

      

Is 102400 the equivalent of 100MB, I don't feel the docs are clear enough on this?

+3


source to share


2 answers


As described in the docs:

max: value

The field under validation must be less than or equal to the maximum value. Lines, numbers and files are evaluated the same as a rule of thumb

So we move on to the size rule:



size: value

The field under validation must have a size corresponding to this value. For string data, the value corresponds to the number of characters. For numeric data, the value corresponds to the specified integer value. For files, the size corresponds to the size of the file in kilobytes .

Thus, 102400 is Kilobytes.

Yes, that's 100 MB.

+6


source


I believe the best way to find out is to check the source on Github .

In particular:



return $value->getSize() / 1024;

According to Wikipedia , a kilobyte "refers to 1000 bytes or 1024 bytes, depending on usage and context," so the documentation seems to be a bit ambiguous.

+2


source







All Articles