Last active
January 15, 2020 14:27
-
-
Save kparkov/38a95972de6f6eb2cd70 to your computer and use it in GitHub Desktop.
Multer uploads #javascript #node
This file contains 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 File uploads | |
body | |
form(method="post", action="/file", enctype="multipart/form-data") | |
input(type="file", name="file") | |
input(type="submit", value="Upload") |
This file contains 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 router = express.Router(); | |
var multer = require("multer"); | |
var upload = multer({ dest: "/tmp/" }); | |
router.post('/file', upload.single('file'), (req, res, next) => { | |
// req.file contains what you need. | |
}); | |
module.exports = router; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment