413: File entity too large ugly error When uploading an image that exceeds the server PHP upload image, I get the following error: 



My question is: Why is this error displayed so ugly and is there a way to display it more nicely, for example, in the form itself?

To be clear: I know why this error is thrown, it's just a matter of userfriendliness.
If you are experiencing it on Chrome only it's a problem with your setup, not Drupal itself. Here you have a bug report about it.

But more probable is that it happens on all browsers, and it's a problem with nginx config - you need to set up client_max_body_size about 35% larger than max file size you want to allow people to upload using Drupal (to have safety margin for Base64 and alike). That way your Drupal will catch "to large" exceptions, and not your nginx.

Note - HTTP does not force body encoding, so 35% margin may well stay unused. But nothing stops applications from doing it, and 35% is what I experienced to be safest bet to avoid future surprises. Hardly any encoding or wrapping wastes as much as Base64 with it's 4/3 overhead. Better safe than sorry and if your server is willing to accept 20MB files, then 27MB will not kill it.