Last active
December 19, 2019 08:13
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
const express = require("express"); | |
const bp = require("body-parser"); | |
const port = 5000; | |
const app = express(); | |
const multer = require("multer"); | |
app.use(bp.urlencoded({ extended: false })); | |
app.use(bp.json()); | |
app.use(require("morgan")("dev")); | |
var storage = multer.diskStorage({ | |
destination: function(req, file, cb) { | |
cb(null, "./"); // here we specify the destination . in this case i specified the current directory | |
}, | |
filename: function(req, file, cb) { | |
console.log(file); | |
cb(null, file.originalname);// here we specify the file saving name . in this case i specified the original file name | |
} | |
}); | |
var uploadDisk = multer({ storage: storage }); | |
app.post("/fileuploaddisk", uploadDisk.single("image"), (req, res) => { | |
console.log(" file disk uploaded"); | |
res.send("file disk upload success"); | |
}); | |
app.listen(port, () => { | |
console.log("Express server listning on port " + port); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment