Illuminate \ Http \ Exceptions \ PostTooLargeException

后端 未结 4 856
眼角桃花
眼角桃花 2021-02-14 15:24

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 16:00

    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

提交回复
热议问题