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?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community