I'm trying to handle PostTooLargeException in laravel 9 without updating php.ini file.
In app/Exceptions/Hndler.php I have call below renderable function
use Illuminate\Http\Exceptions\PostTooLargeException as PostTooLargeException;
public function register()
{
$this->renderable(function (PostTooLargeException $e, $request) {
return response()->view('errors.custom', [], 500);
});
}
Controller add action
public function add( \App\Http\Requests\AuthorFormRequest $request )
{
dd($request)
}
AuthorFormRequest Is like below
public function rules()
{
return [
'user_icon' => 'image|mimes:jpg,png,jpeg,gif,svg|max:2048|dimensions:min_width=100,min_height=100',
'name' => 'required|string|max:30',
'group' => 'nullable|string|max:30',
'position' => 'nullable|string|max:30',
'category' => 'nullable|string|max:30',
'description' => 'nullable|string|max:200',
'stripe_id' => 'email',
'image_tmp' => 'nullable|string'
];
}
Every time I'm getting below image if image size is 1gb.
My expectation is display the error message as a session message in upload page. How will handel this error ?