question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Intuitive method for handling multi-part text fields

See original GitHub issue

@LinusU @jpfluger we need to have an intuitive method for handling text fields in multi-part forms.

Although upload.single(), upload.array(), upload.fields() work, it is unintuitive to call them (file handling methods) when there are no files to be uploaded.

Maybe we could extend their behavior to handle text fields?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:17 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
LinusUcommented, Jul 23, 2015

@hacksparrow That form could be handled by the code below. Is there any validations that you want to make? Should it only allow the text fields username and areacode?

app.post('/form', upload.fields([]), function (req, res) {
  // req.body === { username: _, areacode: _ }
})
0reactions
anthonylancommented, Mar 8, 2020

@hacksparrow That form could be handled by the code below. Is there any validations that you want to make? Should it only allow the text fields username and areacode?

app.post('/form', upload.fields([]), function (req, res) {
  // req.body === { username: _, areacode: _ }
})

Thanks for your reply but how do you get them to the server? Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling multipart form data with express JS-values from text ...
The console.log(d) returns an empty object. Without multipart/form-data the image doesn't get uploaded,but the rest of the data gets recorded.
Read more >
input - What's the best and most intuitive way to have a user ...
Have one text field where they can enter values. This becomes a moderately complex parsing problem if more than one or two formats...
Read more >
Handling File Upload Using Ruby on Rails 5 API - Pluralsight
In this guide we will examine the two main approaches of handling file uploads, multipart form data and base64 encoding, through a Rails...
Read more >
POST method uploads - Manual - PHP
POST method uploads ¶. This feature lets people upload both text and binary files. With PHP's authentication and file manipulation functions, you have...
Read more >
HTTPie 3.2.1 (latest) docs
Expressive and intuitive syntax · Formatted and colorized terminal output · Built-in JSON support · Forms and file uploads · HTTPS, proxies, and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found