Triumfator's avatar

Laravel 5.8 strange image upload validation error

Is it just me or is image validation uploading in Laravel 5.8 doesn't work properly? My form is configured correctly in blade view

<form action="{{url('admin/itemimageupload')}}" enctype="multipart/form-data" method="post">
<input required type="file" class="form control form-control-sm" id="files" name="images[]" multiple>

Controller validation

$request->validate([
    'images' => 'required',
        'images.*' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048'
        ]);

When I try to upload a VIDEO file, it shouldn't be allowed and i should get an error saying that, but instead i laravel throws a PostTooLargeException

Illuminate \ Http \ Exceptions \ PostTooLargeException No message

When I upload an 1 JPG file that's bigger than 2MB, I get the following error displayed in the errors output section of form blade view file.

The images.0 failed to upload.

When I try to upload 2 or more JPG files that are all larger than 2MB, I get thrown the same PostTooLargeException.

0 likes
3 replies
Triumfator's avatar
Triumfator
OP
Best Answer
Level 1

I fixed this by changing the values of "post_max_size" & "upload_max_filesize" in php.ini to 128mb instead of 2 MB.

1 like
devHasan's avatar

Thanks man but still ,i am having the issue when i try to upload the video file it doesn't throw any validation error

Please or to participate in this conversation.