Illuminate \ Http \ Exceptions \ PostTooLargeException

后端 未结 4 2066
感动是毒
感动是毒 2021-02-14 08:01

I already configured php.ini file (post_max_size=10240M), but it\'s still throwing PostTooLargeException. How to increase upload and download limit in Laravel 5.5?

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-14 08:41

    1) If you change the post_max_size from php.ini and restart the apache server but after does not get proper response then you have temp solution.

    Handle the illuminate-http-exceptions-posttoolargeexception exception

    public function render($request, Exception $exception)
    {
        if ($exception instanceof \Illuminate\Http\Exceptions\PostTooLargeException) {
            return redirect()->back()->withErrors(['File size is too large']);
        }
        return parent::render($request, $exception);
    }
    

    and display the error in your view file

    @if ($errors->any())
        @foreach ($errors->all() as $error)
                        
    {{ $error }}
    @endforeach @endif

提交回复
热议问题