Search code examples
node.jsformsformidable

why does formidable 'multiple' select not work with 'multipart/form-data'?


I have tried many ways to parse 'multiple' select options as an array from a from with enctype='multipart/form-data' but it only shows the last selected item.

I want to upload files and a select input with multiple='multiple', but it seems like with formidable I can only afford one of them. Formidable retrieves the select input fine with a normal form, but only the last one with multipart form.

Anybody knows a workaround with that problem?


Solution

  • package.json

    {
      ...
      "dependencies": {
        "formidable": "^2.0.1"
      }
    }
    

    index.js

    const formidable    = require('formidable')
    
    const form = formidable({ multiples: true });
    

    Example: select multiple

    Ref: https://www.npmjs.com/package/formidable