About upload image in Node.js

I was seen some stackoverflow about this question.

In the jade.

form.editUserForm(name="editUser", action="/upload", method="post")
    input(placeholder="Select you photo" type="file", name="thumbnail")
    input.ui.blue.submit.button(type="submit", value="Submit")

In the js.

app.post('/upload', function (req, res) {
    console.log(req.files);
    console.log(req.body);
}

I found the 'req.files' is 'undefined', so I cannot use the code below.

app.post('/upload', function (req, res) {
    var tmp_path = req.files.thumbnail.path;
    target_path = '/tmp/' + req.files.thumbnail.name;
    fs.rename(tmp_path, target_path, function(err) {
        if (err)
            throw err;
        fs.unlink(tmp_path, function() {
            if (err)
                throw err;
        });
    });
});

You have to set the enctype attribute of your form to the value multipart/form-data:

form.editUserForm(name="editUser", action="/upload", method="post", enctype="multipart/form-data")