thevan thevan - 1 year ago 434
Node.js Question

How to get textbox value in node.js file?

This is my html code:

<form id="fileupload" method="POST" enctype="multipart/form-data">

<div class="row fileupload-buttonbar">
<textarea name="txtFolderName" rows="1"></textarea>
<button type="create" class="btn btn-primary start">
<i class="glyphicon glyphicon-upload"></i>
<span>Create Folder</span>

When I click the "Create Folder" button, I will do some function based on the textbox value. How to get the textbox value to the node.js file during POST method?

Answer Source

For express you can use bodyParser() middleware ( and get submited fields from req.body.

var express    = require('express');
var bodyParser = require('body-parser');

var app = express();
app.use(bodyParser());'/uploaded',function(req, res, next){
    var txt_folder_name = req.body.txtFolderName;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download