Multer: Wrong error triggered when number of fields exceed maxCount with .array(fieldname[, maxCount])

Created on 2 Oct 2016  路  3Comments  路  Source: expressjs/multer

I use upload.array('files', 5).

When I send from 1 to 5 files, everything works great !
But when I send 6 files I got the following error :
{ [Error: Unexpected field] code: 'LIMIT_UNEXPECTED_FILE', field: 'files', storageErrors: [] }

According to make-error.js I should get this code LIMIT_FILE_COUNT right ? Or am I missing something ?

future

Most helpful comment

I was just thinking about this the other day... It feels kind of strange to get LIMIT_UNEXPECTED_FILE actually.

As it is now, LIMIT_FILE_COUNT is only returned when the global (opposed to per-field) file limit is hit.

Changing this would be a breaking change, although I think it's a good change. I'll add it to the 2.0 alphas shortly, track progress here: #399

All 3 comments

I was just thinking about this the other day... It feels kind of strange to get LIMIT_UNEXPECTED_FILE actually.

As it is now, LIMIT_FILE_COUNT is only returned when the global (opposed to per-field) file limit is hit.

Changing this would be a breaking change, although I think it's a good change. I'll add it to the 2.0 alphas shortly, track progress here: #399

You can try it out right now with npm install --save multer@next 馃帀

Works great 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

trexanhvn picture trexanhvn  路  3Comments

bpetty-formfast picture bpetty-formfast  路  3Comments

josephstgh picture josephstgh  路  3Comments

BlueOctober picture BlueOctober  路  3Comments

Paul-Morris picture Paul-Morris  路  3Comments