// file-upload.middleware.js
import multer from 'multer';
// Configure storage for uploaded files
const storageConfig = multer.diskStorage({
destination: (req, file, cb) => {
cb(null, 'public/uploads'); // Destination folder for uploads
},
filename: (req, file, cb) => {
const fileName = Date.now() + file.originalname; // Unique filename
cb(null, fileName);
}
});
// Multer middleware for handling file uploads
export const uploadFile = multer({ storage: storageConfig });
Created
January 23, 2024 05:38
-
-
Save vivekyadav5750/a5cae69f251eac9a3753b8db312a138e to your computer and use it in GitHub Desktop.
Nodejs Image/File Upload (use Multer Module)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment