Illuminate \ Http \ Exceptions \ PostTooLargeException

后端 未结 4 2073
情书的邮戳
情书的邮戳 2021-02-14 15:30

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 15:47

    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

提交回复
热议问题