Skip to content

Instantly share code, notes, and snippets.

@heytulsiprasad
Created February 25, 2020 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heytulsiprasad/a3ab87b4c06abba2bc11a3689eb3c7ab to your computer and use it in GitHub Desktop.
Save heytulsiprasad/a3ab87b4c06abba2bc11a3689eb3c7ab to your computer and use it in GitHub Desktop.
get started with multer npm package for uploading files
// index.js >>> root file of /src
const multer = require("multer")
const express = require("express")
const app = express()
const upload = multer({
dist: "images"
})
app.post("/user/avatar", upload.single("avatar"), (req, res) => {
res.send();
})
// "avatar" in upload.single refers to the key value provided in form-data
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment