![](/img/trans.png)
[英]How can I Get element by data attribute in string and get the inner text in a node.js application?
[英]How can I get the “name” attribute in node.js
<input type='file' name='upload1'/>
提交此表單后,如何在node.js上獲取“名稱”屬性(upload1)。 我使用restify,並上傳圖片。
只需將node-formidable用於文件上傳。
在node.js中,正確的方法是使用網絡應用程序框架(例如express)。 它為您提供更多選擇和靈活性。 快遞您可以:
var express = require('express'); //Initialize express
var app = express();
app.listen(3000);
app.use(express.bodyParser()); //to parse the forms
app.post('/pagesubmit', function(request, response){ //to handle POST to the page
console.log(request.body.username); //tp access input text 'username'
console.log(request.files.name); //to access input file 'name'
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.