Form File Upload - Unfriendly UI response when uploading large files

Created on 12 March 2017, over 8 years ago
Updated 6 October 2025, 23 days ago

I created a file upload form in Drupal 8. When I try to exceed the PHP file limit (as a web visitor might), I get the following error message:
"An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (6 MB) that this server supports."

This error message is not friendly for standard web visitors. I've made this comment before, but warning and error messages should not be in developer-speak (unless that truly is the target audience). In this case this error message will be seen by standard web visitors, and it won't make sense to them, and it's unfriendly.

The other issue is that the error message completely obliterates the file upload form, so it's not like the user can try uploading another file.

A better solution would be a warning like 'Warning: the file you tried to upload is too large. Please try a smaller file (preferably smaller than X MB)'. This error message should also not obliterate the file upload form, but instead go above it, where other form validation errors go.

We should try to avoid error messages like 'unrecoverable'. This error is entirely recoverable. We just need to let the user know, so they can try again.

We might decide to have different error messages for development site, and a production site. Maybe a developer error message might be "Warning: the web server is not configured to accept files larger than 6MB. You are using Apache, so check out [useful link here] to find out how to reconfigure this."

I've noticed on forums that people waste hours due to less than useful error messages. One error message can take 30 minutes to write, if we think about it carefully, but it could waste hundreds of years if we multiply out time wasted. So it's a worthwhile endeavour to improve error messages. It's hard to get error messages right though, I admit that, because the logic during error conditions can be unpredictable, which is where better error catching via code, comes in I guess. Not easy to do well.

Anyway, I'm hoping this comes across as constructive feedback. I'm interested in making the upload form more user friendly. There are some other issues I've found. I've only been using Drupal a couple of weeks, but still up for getting my hands dirty, if anyone feels that's acceptable.

Feature request
Status

Postponed: needs info

Version

11.0 🔥

Component

forms system

Live updates comments and jobs are added and updated live.
  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024