Last active
April 25, 2019 15:18
-
-
Save hakobyansen/cb6e000ab130f64ab676aee45d3ba92a to your computer and use it in GitHub Desktop.
Even if you have file size validation implemented, you will get PostTooLargeException if you're trying to upload file larger than size specified in your php.ini config file. This gist shows how you can handle PostTooLargeException in Laravel.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // App\Exceptions\Handler::render() | |
| public function render($request, Exception $exception) | |
| { | |
| if ($exception instanceof PostTooLargeException) | |
| { | |
| // todo: return response or do whatever you need to do | |
| return response()->json(['message' => 'File is too large.'], 422); | |
| } | |
| return parent::render($request, $exception); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment