StuBlackett
StuBlackett

Reputation: 3857

Laravel 4 - Validator - File Size

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.

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

My controller code is as follows :

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

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

Upvotes: 3

Views: 3812

Answers (2)

Onion
Onion

Reputation: 1832

I believe the best way to find out would be to check the source at Github.

Specifically:

return $value->getSize() / 1024;

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

Upvotes: 2

Loko
Loko

Reputation: 6679

As described in the docs:

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:

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.

So the 102400 is Kilobytes.

Yes that is 100 MB.

Upvotes: 6

Related Questions