Skip to content

Commit 3bbacda

Browse files
committed
doc
1 parent 34f8031 commit 3bbacda

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

doc/day1_express.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ http.createServer(function(request,response){
4848
这就是最简单的实现
4949

5050
## Node connect 版本的http server
51+
5152
Connect is an extensible HTTP server framework for node using "plugins" known as middleware.
5253

5354
```
@@ -233,6 +234,7 @@ app.post('/someur',function(req,res){
233234
res.send('hello,world');
234235
});
235236
```
237+
236238
### session
237239

238240
一个session就是一系列某用户和服务器间的通讯。服务器有能力分辨出不同的用户。
@@ -518,6 +520,32 @@ module.exports = router;
518520

519521
### 如何实现文件上传
520522

523+
什么是多部请求?
524+
525+
var app = express();
526+
var multer = require('multer')
527+
528+
app.use(multer({
529+
dest: './uploads/',
530+
rename: function (fieldname, filename) {
531+
return filename.replace(/\W+/g, '-').toLowerCase() + Date.now()
532+
}
533+
}))
534+
535+
在路由里
536+
537+
router.post('/post/formdata', function(req, res) {
538+
// res.send('respond with a resource');
539+
console.log(req.body, req.files);
540+
console.log(req.files.pic.path);
541+
res.json(req.body);
542+
});
543+
544+
这里的req.files就可以渠道对应的files的详情,该放到db或者云存储就大胆的存储
545+
546+
### 更多http相关的
547+
548+
请查看[http](https://github.com/nodeonly/nodejs-tutorial/blob/master/doc/demo/day1/http/readme.md)
521549

522550
### request里如何取值
523551

0 commit comments

Comments
 (0)