Multer not accepting files in array format gives 'Unexpected File Error'

前端 未结 2 1183
南旧
南旧 2020-12-31 12:21

Multer is a module used along with node js and express to upload files. I am using ng-file upload module on the angular side.

When I am sending multiple files one b

2条回答
  •  -上瘾入骨i
    2020-12-31 12:50

    The reason for the error is that multer currently does not support the array syntax that ng-file-upload uses by default which is files[0], files[1], files[2], etc. multer is expecting a series of files with the same field name.

    The easiest solution is to set ng-file-upload's arrayKey option like so to avoid appending the [index] part:

    Upload.upload({
      url: '/api/data/addtweet',
      arrayKey: '', // default is '[i]'
      data: {
        files: files
      }
    })
    

提交回复
热议问题