In this tutorial, we will discuss how to use laravel min file size and max file size validation. laravel max and min file size validation in kilobytes. File size validation in laravel 7, laravel 8 and laravel 9. laravel file size validation not working. All types of laravel file size validation.
Laravel exact file size upload validation
When we want upload an image or file of an exact size then use size validation and here we define exact size of file. Below example allow only upload file which size exactly 1000kb.
$validator = Validator::make($request->all(), [ 'file' => 'size:1000', ]);
Laravel min and max file size validation
laravel max file size validation validates the maximum size of a file and min file size validation validates the minimum size of a file or we can also validate a file size between the max and min range.
$validator = Validator::make($request->all(), [ 'file' => 'min:500|max:5000', ]);