Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Validate Array of Files Total Allowable Upload Size

Tags:

My View has an array of file inputs like

<input type="file" name="videos[]" />
<input type="file" name="videos[]" />
...
...

and I want to validate for the total allowable upload size (Eg: Total Allowable Upload limit is 3Mb). I've written the validation like

$validatedData = $request->validate([
     'videos.*' => 'present|file|mimetypes:video/mp4,video/ogg|max:3000',
]);

but this validates for 3Mb per video.

I've tried

$validatedData = $request->validate([
    'videos' => 'file|max:3000',
    'videos.*' => 'present|file|mimetypes:video/mp4,video/ogg|max:3000',
]);

/*------------------------------------------------*/

$validatedData = $request->validate([
    'videos' => 'array|max:3000',
    'videos.*' => 'present|file|mimetypes:video/mp4,video/ogg|max:3000',
]);

but the validation is not working for total upload size greater than 3Mb. Do I have to write a Custom Validation Rule to validate the total uploaded file size limit. Or is there any predefined validation rule? Any help appreciated.

Thank You!


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!