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.

How not to upload with form.parse() ?

See original GitHub issue

Context

  • node version: 12.14.1
  • module (formidable) version: canary
  • environment (e.g. node, browser, native, OS): Nodenv, Chrome, WSL2, Win10 Pro
  • used with (i.e. popular names of modules): express, mysql
  • any other relevant information: -

What problem are you trying to solve?

I have a problem with using formidable, it’s a simple but I can’t find any site with this problem.

“In case I have a upload webapp with formidable, how not to upload an empty file? It always upload an empty file, title like upload_3f0934128511fd38dha1… and no content”

I’m using this module like below in expressJS

router.post('/compose', async function (req, res, next) {  
if (req.body.imgFile == undefined ) { // no upload }
else {
    form.parse(req, async (err, fields, files) => {
    // some business logic
    }
}

but it doesn’t work anyway. I think form.parse() has no option to not upload.

So if form.parse() in formidable has a function to make webapp upload or not, plz comment below. Or same function with same feature, plz comment

thx

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
tunnckoCorecommented, Apr 23, 2020

I think the callback to parse cannot be async function, yea, use the event API.

1reaction
leonardovillelacommented, Dec 27, 2020

I think can be removed as a pinned issue in this repository.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Formidable doesnt form.parse() when uploading a file in Nodejs
On the Internet I read that this is because I use bodyParser(), and people suggested to do this: delete express.bodyParser.parse['multipart/form-data'];.
Read more >
Uploading Files using Formidable in a Node.js Application
In this article, we will learn how we can upload files using node.js, express, and formidable. Formidable is a Node.js module for parsing...
Read more >
Null in Parse JSON when Upload in Forms is Optional
Hi Thomas, Try moving the parse JSON step to the "If No" side of the condition. Right now your flow says, if there's...
Read more >
Differences between formidable callbacks, events ... - Medium
Formidable is a NodeJS module to uploading files. ... Cause formidable is not a promise. ... parseAsync() instead of form.parse() .
Read more >
Top 5 formidable Code Examples - Snyk
flow: function (req, res, next) { var form = new formidable.IncomingForm(), userSlug = slug(req.headers['uid']), uploadDir = './uploads/' + userSlug; fs.
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