laravel on live server - why validation gives an internal server error when a great amount of data is submitted?

Viewed 691

I'm facing a weird problem with my laravel 5.8 app only in a live server, whenever we submit a great number of characters(about 5000) in a form we're getting

internal server error

I realize that this happens in the validation part, if I remove it (and enter a lot of data), it works perfectly and inserts well in the database, here is my controller code:

        public function createAuthor(Request $request)
            {


                request()->validate(
                    [
                        'name' => ['required', 'min:3'],
                        'email' => ['required', 'email', 'unique:users,email'],
                        'password' => ['required', 'confirmed', 'min:8'],
                        'password_confirmation' => ['required'],
                        'acepto' => ['required'],
                        'biography' => ['max:500'],
                        'state_id'  =>  ['required'],
                        "country" => "required_if:state_id,==,33",
                        'image' => ['mimes:jpeg,png,jpg', 'max:500'],
                    ],
//rest of code inserting data to database....

The validation doesn't seem to have any syntax error.

If only a few characters are inserted in the form's inputs, everything works perfectly with the validation.

Also if we check the code out after the internal error I see this:

[Thu Jun 27 21:31:57.339455 2019] [http:error] [pid 2633339:tid 140420960212736] [client 10.80.0.107:62547: Response header name expires=Fri, 28-Jun-2019 06' contains invalid characters, aborting request, referer:

also another simple example could be this simple code:

    public function store(Request $request)
        {

            $request->validate(
                [
                    'post_title' => ['required', 'min:3'],
                    ]);

    }

My form points to that store function and simply with that is enough to start getting internal server errors only when a lot of characters are presented.

Also I increased the memory_limit, post_max_size and upload_max_filesize to 1G, and nothing.

Any idea of how to solve it? thanks.

1 Answers

validate like this:

$rules = ['name' =>'required', 'min:3',
                    'email' => 'required', 'email', 'unique:users,email',
                    'password' => 'required', 'confirmed', 'min:8',
                    'password_confirmation' => 'required',
                    'acepto' => 'required',
                    'biography' => 'max:500',
                    'state_id'  =>  'required',
                    "country" => 'required_if:state_id,==,33',
                    'image' => 'mimes:jpeg,png,jpg', 'max:500'];
        $validator = Validator::make($request->all(), $rules);
        if (!$validator->fails()) {
         }
     else{
   //validation error message
   }
Related