<input type='file' name='upload1'/>
When this form is submitted,how can I get the "name" attribute (upload1) on node.js. I use restify,and upload image.
只需将node-formidable用于文件上传。
The right way in node.js is would be to use a web app framework like express. It gives you more options as well as flexibility. In express you can do :
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'
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.