-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver8.js
46 lines (38 loc) · 1007 Bytes
/
server8.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const express = require('express')
const multer = require('multer')
const app = express()
const mystorage = multer.diskStorage({
destination:function(req,file,cb){
cb(null,"uploads")
},
filename:function(req,file,cb){
cb(null,file.originalname)
}
})
const upload = multer({
// dest:'uploads/'
storage:mystorage,
fileFilter:function(req,file,cb){
if(file.mimetype == "image/jpeg" || file.mimetype == "image/x-png"){
cb(null,true);
} else{
cb(null,false);
cb(new Error("Valid Extensions are jpeg/png"))
}
},
limits:{
fileSize:1024*1024*12
}
})
app.post('/signup',upload.single('profilepic'),function(req,res){
//req.file is the `avatar` file
//req.body will hold the text fields,if there were any
console.log(req.body);
console.log(req.file);
res.json({
msg:"Signup done",
status:200,
data:"Signup done"
})
})
app.listen(9999)