Search code examples
phpjquerylaravellaravel-formrequest

Form tag with request of more 1000+ request not able get in controller in laravel


When I am requesting all parameters than it is giving me NULL

My Controller store function as:

public function store(Request $request)
{
     dd($request->all());
}

My view file as:

@extends('main')
@section('content')

<form class="add_form" id="add_form">
@csrf
<input type="text" name="param_1" >
.
.
.
.
till 1450 parameters
<button type="button" id="submit" >Submit</button>
</form>

@endsection
@push('scripts')

<script type="text/javascript">
  $(document).ready(function(){
    $("#submit").on("click",function(e){
      
        $.ajax({
          type:"POST",
          url:"{{ route('froms.store') }}",
          data: new FormData($('#add_form')[0]),
          processData: false,
          contentType:false,

          success: function(data){
            if(data.status==='success'){
                  location.reload();
            }else if(data.status==='error'){
                  location.reload();
            }
          }
        });
      
    });
  });
</script>

@endsection

Output that I am getting on store function is NULL

Now problem with this is that if I am using parameters less than 1000 than I am getting all request in my controller but when I am using it with more than that not able get request

Apart It is compulsory to have all request at a time not able to do parietal forms also.


Solution

  • I think this issue is related to PHP configuration (php.ini) file Check the post_max_size and max_input_vars increase these values if necessary.

    You can find php.ini file on linux on given path.

    /etc/php/7.4/apache2/php.ini
    

    enter image description here

    enter image description here

    Or you can try JSON.stringify() function while sending ajax request. By using this you can reduce the size of the data being sent in the AJAX request

    For More information read stackoverflow thread.

    Tried this scenario on my local environment enter image description here