This commit is contained in:
MishaBagger
2023-11-08 13:41:29 +03:00
parent 797df1e4fa
commit 0956275ec4
24 changed files with 4184 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
const multer = require("multer");
const storage = multer.diskStorage({
destination: function (req, file, cb) {
return cb(null, "./uploads");
},
filename: function (req, file, cb) {
return cb(null, `${Date.now()}-${file.originalname}`);
},
});
const upload = multer({ storage: storage });
const uploadImage = (req, res, next) => {
if (!req.file)
return res.status(400).send(`No file Uploaded <br>
<button onclick="window.location.href='/images'">Show Images</button>
<button onclick="window.location.href='/'">Back to Home</button>
`);
console.log(req.file);
res.send(
`Uploaded <br>
<button onclick="window.location.href='/images'">Show Images</button>
<button onclick="window.location.href='/'">Back to Home</button>
`
);
};
module.exports = { upload, uploadImage };