Skip to content

Commit d90a2a7

Browse files
committed
engine set
1 parent 81793ff commit d90a2a7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

upload a file using multer/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ const path=require('path');
44
const multer=require('multer');
55
const exphbs=require('express-handlebars');
66

7+
//defining storage
8+
var storage=multer.diskStorage({
9+
destination : function(req,file,cb){
10+
cb(null,'./uploads');
11+
},
12+
filename: function(req,file,cb){
13+
cb(null,file.filename+ '-'+ Date.now());
14+
}
15+
})
16+
17+
718
const app=express();
819

920
//set engine
@@ -18,6 +29,11 @@ app.use(bodyparser.urlencoded({extended : false}));
1829
app.use('/public',express.static(path.join(__dirname + 'public')));
1930

2031

32+
app.get('/',function(req,res){
33+
res.status(400).json({msg: "hyyy"});
34+
})
35+
36+
//port is live
2137
const port=3000|| process.env.PORT;
2238
app.listen(port,function(res,err){
2339
console.log(`app is live at ${port}`);

0 commit comments

Comments
 (0)