Laravel: Validate maximum File size?

According to the documentation:

$validator = Validator::make($request->all(), [
    'file' => 'max:500000',
]);

The value is in kilobytes, for example:

  • max:10240 = max 10 MB.

  • max:1 = max 1024 bytes.

Note that there are efforts to change the value of 1 kilobytes from original 1024 to 1000 bytes, but major frameworks like Laravel remain using original 1024 value, which prevents confusion of senior developers (which are used to 1024).

Leave a Comment