POST multiple images in Postman

HOW TO: Validate multiple images input in Lumen/Laravel

In this short post, I will show you how to use the Lumen/Laravel validation to validate multiple images in an array.

1. Make sure you are posting an array of images to your endpoint

images[]

In Postman or whatever testing tool you use, make sure you POST an array of images, not just a single one.

2. Use the following code to check that the request contains an array of images and validate each one of them

$this->validate($request, [
'images' => 'array',
'images.*' => 'mimes:png,jpeg,jpg|max:8000'
]);

Learn more: Laravel – Validation

Question on Stackoverflow

How to solve – No ‘Access-Control-Allow-Origin’ header is present on the requested resource

One thought on “HOW TO: Validate multiple images input in Lumen/Laravel

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.