问题
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>
</button>
</div>
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?
回答1:
For express you can use bodyParser() middleware (https://github.com/expressjs/body-parser) and get submited fields from req.body.
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser());
app.post('/uploaded',function(req, res, next){
var txt_folder_name = req.body.txtFolderName;
//...
});
来源:https://stackoverflow.com/questions/23905547/how-to-get-textbox-value-in-node-js-file