2
<input type='file' name='upload1'/>

このフォームが送信されたとき、node.js で "name" 属性 (upload1) を取得するにはどうすればよいですか? 私はrestifyを使用し、画像をアップロードします。

4

2 に答える 2

0

node.js での正しい方法は、express のような Web アプリ フレームワークを使用することです。より多くのオプションと柔軟性を提供します。エクスプレスでは、次のことができます。

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'
});
于 2013-06-06T13:31:22.267 に答える