Giolf's avatar

Problem with 'max' rule validation

Hi all,
I've a strange problem with "max" rule validation in my FormRequestValidation.

This is my form:

 {!! Form::open(['route' => [$route . '::upload', $person->id], 'files' => true, 'id'  => 'form']) !!}
<div class="row">
    <div class="form-group col-sm-12">
        {!! Form::label('name', 'Nome') !!}
        {!! Form::text('name', null, ['class' => 'form-control', 'pattern' => '[a-zA-Z\s]+', 'required' => "true", 'placeholder' => "Nome dell'allegato"]) !!}
    </div>
</div>
<div class="row">
    <div class="form-group col-sm-12">
        {!! Form::label('file', 'File') !!}
        {!! Form::file('file', ['required' => "true"]) !!}
    </div>
</div>
<div class="row">
    <div class="form-group col-sm-12">
        {!! Form::label('description', 'Descrizione') !!}
        {!! Form::textarea('description', null, ['class' => 'form-control', 'rows' => 3, 'placeholder' => "Descrizione dell'allegato"]) !!}
    </div>
</div>
{!! Form::close() !!}

And in UploadAttachmentRequest i've these rules:

    public function rules()
    {
        return [
            'name' =>  ['required', 'regex:/[a-zA-Z\s]+/'],
            'file' => 'required|max:3000'
        ];
    }

Now if i try to upload a file bigger than 3000 KB the error that come back is coming from the 'file' => 'required' rule but not from the max rule. In fact i get back the message: "file is a required field".
how it is possibile?
thank you

0 likes
2 replies
Giolf's avatar

Solved, i ve just to change the: upload_max_filesize parameter in the php.ini file.

1 like
Juukie's avatar

Yup, that's a common error. I've had it once before too.

1 like

Please or to participate in this conversation.