Created
September 4, 2017 14:46
-
-
Save judges119/8bc5fefe10c40071e90126040a42f886 to your computer and use it in GitHub Desktop.
Basic multer uploads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var multer = require('multer'); | |
var upload = multer({ dest: 'uploads/' }); | |
var app = express(); | |
// View engine | |
app.set('views', __dirname); | |
app.set('view engine', 'pug'); | |
// Routes | |
app.get('/', function (req, res) { | |
res.render('index'); | |
}); | |
app.post('/upload', upload.single('upl'), function (req, res, next) { | |
console.log(req.file); | |
res.send(req.file) | |
}); | |
// Start | |
app.listen(3000, function () {}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doctype html | |
html | |
head | |
title | |
| Multer Uploads | |
body | |
h1 | |
| Multer Uploads | |
form(method='post', action='/upload', enctype='multipart/form-data') | |
input(type='file', name='upl') | |
input(type='submit') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment