dimanche 15 juillet 2018

PostTooLarge Exception Laravel

I have uploaded 15mb image and it throws exception of PostTooLarge Exception instead of exception i have to show flash error message but could not get it.

below is the handler i have used for Handler.php it works great but not display flash message.

if ($exception instanceof \Illuminate\Http\Exceptions\PostTooLargeException) 
{
        return redirect()->route('users.add')->withFlashError('Image Size too large!');
}

then i tried validate of laravel for image in my controller which is as below

$validator = Validator::make($request->all(), [
                'image' => 'max:4000',
            ]);
if ($validator->fails()) 
{
        return redirect()->route('user')->withFlashError('Image size exceeds 4MB');                 
}

but still no luck



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire