Show error message if too many files are selected for upload#2376
Merged
Show error message if too many files are selected for upload#2376
Conversation
added 2 commits
April 4, 2025 15:43
…ded. The file upload form is limited in the number of files it can handle due to design limitations of the Django upload handler. Exceeding the limit set by DATA_UPLOAD_MAX_NUMBER_FILES will currently cause the page to crash (and doesn't give a useful error message.) Display a message to advise authors of this limitation.
The file upload form is limited in the number of files it can handle due to design limitations of the Django upload handler. Exceeding the limit set by DATA_UPLOAD_MAX_NUMBER_FILES will currently cause the page to crash (and doesn't give a useful error message.) To prevent this happening accidentally, disable the submit button and show an error message if too many files are selected.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Django's (default) file upload mechanism is limited in the number of files it can handle (independent of limitations on file size.)
Consequently, Django enforces a hard limit on the number of files and raises an exception if this is exceeded. (Pull #2036 made this limit configurable.)
Note that HTML doesn't allow specifying any limit for multiple-file upload fields.
Try to prevent people hitting the limit by accident, by disabling the submit button through JavaScript if too many files are selected.
For thoughts about better long-term solutions, see issue #2242.