Home > OS >  How to validate array of files in Laravel?
How to validate array of files in Laravel?

Time:07-13

I'm working on a project where every user is able to add multiple product images. I'm using a single form to submit the product which does 2 things in ProductController@store which are creating new product creating images belongs to this product in Images table.

The important part is that I want to allow users to upload total of 10mb of images per product. So mainly I want to validate total files size of the array of images the user trying to update.

I found this solution: Laravel Validate Array of Files Total Allowable Upload Size

This solution is almost 5 years old so I was wondering if there is an easier way, or a more straight forward way to accomplish this?

CodePudding user response:

I have mixed the stackoverflow solution with Laravel's custom validation rule which solved my problem with a modern solution.

https://dev.to/moose_said/create-custom-laravel-validation-rule-for-total-uploaded-files-size-1odb

  • Related