How to get textbox value in node.js file?

纵饮孤独 提交于 2020-01-23 21:29:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!