Skip to content

Instantly share code, notes, and snippets.

@kparkov
Last active January 15, 2020 14:27
Show Gist options
  • Save kparkov/38a95972de6f6eb2cd70 to your computer and use it in GitHub Desktop.
Save kparkov/38a95972de6f6eb2cd70 to your computer and use it in GitHub Desktop.
Multer uploads #javascript #node
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")
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