如何获取node.js文件中的文本框值? [英] How to get textbox value in node.js file?

查看:182
本文介绍了如何获取node.js文件中的文本框值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的html代码:

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>

当我单击创建文件夹"按钮时,我将基于文本框值执行某些功能.如何在POST方法期间将文本框值获取到node.js文件?

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?

推荐答案

出于表达目的,您可以使用bodyParser()中间件(

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;
    //...
});

这篇关于如何获取node.js文件中的文本框值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆