Level 39
Change the method to this:
return [
'photos.*' => 'image|mimes:jpeg,bmp,png|max:2000',
// other validation
]
Hello guys I have done tutorial to upload image files from link: https://laraveldaily.com/upload-multiple-files-laravel-5-4/
But how can I secure file uploads in view. Something like communicate when user will upload file more than 2MB?
Fragment of create.blade.php:
<div class="form-group">
<input type="file" name="photos[]" multiple aria-describedby="fileHelp"/>
<small id="fileHelp" class="form-text text-muted">jpeg, png, bmp - 2MB.</small>
</div>
and rules:
public function rules()
{
$rules = [
'header' => 'required|max:255',
'description' => 'required',
'date' => 'required',
];
$photos = $this->input('photos');
foreach(range(0, $photos) as $index) {
$rules['photos.' . $index] = 'image|mimes:jpeg,bmp,png|max:2000';
}
return $rules;
}
all ok but when I try now to upload file which have got more than 2MB it gives me error:
Illuminate \ Http \ Exceptions \ PostTooLargeException
No message
How can I solve this? Thanks for help.
Please or to participate in this conversation.