formidable is included in Express #264

headwinds opened this Issue Dec 14, 2013 · 9 comments


None yet

9 participants


For people new to formidable and express, I'd suggest that you list this in your readme near top. Just say, are you using Express? If so, you're in luck! It's already included:

credit - see alexi's answer:

I couldn't get the formidable events to fire because I didn't realize that I had to disable the bodyparser in express configuration. Once I learned that, it worked but then the lightbulb went on... I should just use the built in one instead!


Sure, if you want to send a PR for this I'll merge it in. However, it should be phrased a little more generically. Something like "This is a low level package, and if you're using a high level framework such as Express, chances are it's already included in it.". And then link to some discussion that explains how that prevents you from getting the events.


hi, i use formidable with express.
My question: is the fileBegin event in the formidable build for express? I cannot catch it. I can only get the file,progress and end Event.

      var form = req.form;
    .on('error', function(err) {
        throw err;

    .on('field', function(field, value) {

    .on ('fileBegin', function(name, file){

    .on('file', function(field, file) {

    .on('progress', function(bytesReceived, bytesExpected) {

        var percent = (bytesReceived / bytesExpected * 100) | 0;
        console.log('Uploading: %' + percent + '\r');

    .on('end', function() {


I actually ended up backing off the integrated approach and went with Formidable on its own commenting out the line: app.use(express.bodyParser())

But this approach scares me a little because I don't fully understand the consequences of losing the express.bodyParser

I'm definitely capturing all the events listed using Formidable solo though as module that works with Express -- maybe my FileUploadService gist would help


I've actually just been poking around express and connect for the first time and it seems to me that while formidable is still a dependency of connect, the multipart middleware doesn't actually use it since 2.9.

Actually, the multipart middleware now appears to be deprecated and suggests using formidable directly, which I've been looking for an example of, which is how I ended up here.

Perhaps the wording that was added in that pull request should be re-thought... that stackoverflow question and its responses seem to pre-date the removal of formidable from connect's multipart middleware.


As of express 4.0, formidable does not seem to be included anymore with express. Is there plans to provide a connect-formidable then to fill this gap? See also


I use this package , I found a problem:
throw er; // Unhandled 'error' event
Error: ENOENT, open 'C:\my\dir\bd18bf29d6eefc1554e3617a805be49c.png'

I only change: var form = new formidable.IncomingForm(); form.uploadDir = "/my/dir";and then occur this problem ,I hope you solve this problem soon,thanks!


Trying to use formidable, and the docs say it is included with Express. Perhaps it once was, but that is no longer the case.


My way of using express 4 + formidable:

var util, express, formidable, app;
util = require('util');
express = require('express');
formidable = require('formidable');
app = express();
app.route('*').all(function(req, res, next){
  var ref$, form;
  if ((ref$ = req.method.toLowerCase()) === 'post' || ref$ === 'put' || ref$ === 'patch' || ref$ === 'delete') {
    form = new formidable.IncomingForm();
    form.hash = 'md5';
    form.multiples = true;
    form.parse(req, function(err, fields, files){
      if (err != null) {
        console.error('formidable:parse ' + err);
        return res.status(500).send('upload error.');
      } else {
        req.fields = fields;
        req.files = files;
        return console.log('parsed.');
    form.on('end', function(){
      return next();
  } else {
    return next();
app.route('/').get(function(req, res, next){
// upload page here
app.route('/upload').post(function(req, res, next){

if you put this at the beginning of the main app it should emulate the old body-parser


I've implemented a middleware for this. Please refer to #346.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment