OwlCyberSecurity - MANAGER
Edit File: upload.js
// middlewares/upload.js import multer from 'multer'; import path from 'path'; import fs from 'fs'; const storage = multer.diskStorage({ destination: function (req, file, cb) { const uploadPath = 'uploads/'; if (!fs.existsSync(uploadPath)){ fs.mkdirSync(uploadPath, { recursive: true }); } cb(null, uploadPath); }, filename: function (req, file, cb) { const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1e9); cb(null, uniqueSuffix + path.extname(file.originalname)); }, }); const upload = multer({ storage }); export default upload;