Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'formidable' module has a bug, can't parse array when 'multipart/form-data' #280

Closed
simonhao opened this issue Apr 3, 2014 · 2 comments
Closed

Comments

@simonhao
Copy link

simonhao commented Apr 3, 2014

I submit a form. and content-type is 'multipart/form-data'.
such as:

<form>
<input type="file" name="cover"/>
<input type="text" name="city"/> <!--value = beijing-->
<input type="text" name="city"/>  <!-value = shanghai-->
</form>

but i only get a field city=shanghai not a array.
this bug in 'file lib/incoming_form.js' line 82.

@xarguments
Copy link
Collaborator

Yes, this comes from this part:

      .on('field', function(name, value) {
        fields[name] = value;
      })

it should be handled like this (like files):

      .on('field', function(name, value) {
          if (fields[name]) {
            if (!Array.isArray(fields[name])) {
              fields[name] = [fields[name]];
            }
            fields[name].push(value);
          } else {
            fields[name] = value;
          }
      })

@xarguments xarguments pinned this issue Jan 30, 2019
@xarguments xarguments added this to the 1.3.1 milestone Jan 30, 2019
Amit-A added a commit to Amit-A/node-formidable that referenced this issue Mar 2, 2019
@tunnckoCore tunnckoCore unpinned this issue Jun 3, 2019
tunnckoCore added a commit that referenced this issue Nov 30, 2019
@tunnckoCore
Copy link
Member

Please try npm install formidable@canary - preview of v2. The API is almost the same, check the docs or open new issue if there's some problem.

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 a pull request may close this issue.

4 participants