Skip to content

feat: add filename to LIMIT_FILE_SIZE error#1416

Open
UjjwalKumar239 wants to merge 2 commits into
expressjs:mainfrom
UjjwalKumar239:fix/filesize-error-filename
Open

feat: add filename to LIMIT_FILE_SIZE error#1416
UjjwalKumar239 wants to merge 2 commits into
expressjs:mainfrom
UjjwalKumar239:fix/filesize-error-filename

Conversation

@UjjwalKumar239

Copy link
Copy Markdown

Problem

Fixes #607

When multiple files are uploaded and one exceeds the file size limit,
the MulterError only exposes err.field (the form field name).
This makes it impossible to tell the user which specific file was rejected.

Fix

  • Added optional filename parameter to MulterError constructor
  • When LIMIT_FILE_SIZE triggers, both err.field (fieldname)
    and err.filename (original filename) are now available
  • Fully backward compatible — err.field is unchanged

Testing

Updated test/error-handling.js to assert err.filename is set correctly.
72 tests passing.

When a file exceeds the size limit, the MulterError now includes
a filename property alongside the existing field property.
This allows users to identify which specific file was rejected,
not just which form field it came from.

Closes expressjs#607
When a file exceeds the size limit, the MulterError now includes
a filename property alongside the existing field property.
This allows users to identify which specific file was rejected,
not just which form field it came from.

Also fixed hardcoded Unix path separator in test/functionality.js
for cross-platform compatibility on Windows.

Closes expressjs#607
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filesize in mutliple upload returns fieldname instead of filename

2 participants