nodejs创建一个http服务器来接收上传的文件
nodejs创建一个http服务器来接收上传的文件。需要一段完整代码或者电子档教程文件。谢谢!...
nodejs创建一个http服务器来接收上传的文件。
需要一段完整代码或者电子档教程文件。
谢谢! 展开
需要一段完整代码或者电子档教程文件。
谢谢! 展开
2个回答
展开全部
时间有限。自己看
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
var connect = require('connect')
var http = require('http')
var app = connect()
var multipart = require('connect-multiparty');
// parse urlencoded request bodies into req.body
var bodyParser = require('body-parser')
app.use(bodyParser.urlencoded())
app.use(multipart())
// respond to all requests
app.post('/upload', function(req, resp) {
console.log(req.body, req.files);
// don't forget to delete all req.files when done
});
//create node.<a href="https://www.baidu.com/s?wd=js&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3PAuWP1T4rH9-nyRzPADk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6K1TL0qnfK1TL0z5HD0IgF_5y9YIZ0lQzqlpA-bmyt8mh7GuZR8mvqVQL7dugPYpyq8Q1DvrH0YPWmsrjRdnWR3Pjn4rj6" target="_blank" class="baidu-highlight">js</a> http server and listen on port
http.createServer(app).listen(3000)
参考 : https://github.com/senchalabs/connect
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
var connect = require('connect')
var http = require('http')
var app = connect()
var multipart = require('connect-multiparty');
// parse urlencoded request bodies into req.body
var bodyParser = require('body-parser')
app.use(bodyParser.urlencoded())
app.use(multipart())
// respond to all requests
app.post('/upload', function(req, resp) {
console.log(req.body, req.files);
// don't forget to delete all req.files when done
});
//create node.<a href="https://www.baidu.com/s?wd=js&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3PAuWP1T4rH9-nyRzPADk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6K1TL0qnfK1TL0z5HD0IgF_5y9YIZ0lQzqlpA-bmyt8mh7GuZR8mvqVQL7dugPYpyq8Q1DvrH0YPWmsrjRdnWR3Pjn4rj6" target="_blank" class="baidu-highlight">js</a> http server and listen on port
http.createServer(app).listen(3000)
参考 : https://github.com/senchalabs/connect
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
时间有限。自己看
var connect = require('connect')
var http = require('http')
var app = connect()
var multipart = require('connect-multiparty');
// parse urlencoded request bodies into req.body
var bodyParser = require('body-parser')
app.use(bodyParser.urlencoded())
app.use(multipart())
// respond to all requests
app.post('/upload', function(req, resp) {
console.log(req.body, req.files);
// don't forget to delete all req.files when done
});
//create node.js http server and listen on port
http.createServer(app).listen(3000)
参考 : https://github.com/senchalabs/connect
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询