Support the ongoing development of Laravel.io →
Input Validation

I wanted to apply validation to files that already exist on the local file system, just using the standard validator.

I've set some basic validation rules: it's required and must be an image with a maximum file size.

The file loads just fine, and I know for a fact it meets those validation rules - but the validator doesn't appear to understand the $local_file as a type - so, it always fails validation.

Here's my sample code:

$local_file = File::get(public_path() . '/local_file.jpeg');

$validator = Validator::make(
	array('image' => $local_file),
	array('image' => 'required|image|max:3000')
);

if ($validator->fails())
{
...
}

Is there another approach I can take?

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

jayhealey jayhealey Joined 26 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.