File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
upload a file using multer Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,17 @@ const path=require('path');
44const multer = require ( 'multer' ) ;
55const 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+
718const app = express ( ) ;
819
920//set engine
@@ -18,6 +29,11 @@ app.use(bodyparser.urlencoded({extended : false}));
1829app . 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
2137const port = 3000 || process . env . PORT ;
2238app . listen ( port , function ( res , err ) {
2339 console . log ( `app is live at ${ port } ` ) ;
You can’t perform that action at this time.
0 commit comments