PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, July 30, 2022

[FIXED] How to validate array of files in Laravel?

 July 30, 2022     laravel, laravel-9, php, validation     No comments   

Issue

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?


Solution

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



Answered By - Mostafa Said
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing