basically the title that i am getting nothing from the browser and also postman, I cannot even see print the console.log statements because it just stuck on object Object.
const multer = require(“multer”);
const path = require(“path”);
// Multer configuration
const storage = multer.diskStorage({
destination: path.join(__dirname, “../public/uploads/”), // Destination folder for uploads
filename: (req, file, cb) => {
cb(
null,
file.fieldname + “-” + Date.now() + path.extname(file.originalname)
);
},
});
// Multer instance for single file upload
const upload = multer({
storage: storage,
limits: { fileSize: 5000000 }, // 5MB file size limit
}).single(“filePath”); // ‘filePath’ should match the name attribute in your HTML form input
module.exports = upload;
my html file name tag is the same as “single(“filePath”);
I have tried doing changes that i first included multer config in directly app.js file then in the controller which was using it then a separate file and i got the same result.
This below is my folder structure
(https://i.sstatic.net/FyrcWSLV.png)
(https://i.sstatic.net/51E4VALH.png)
Muhammad Hamood Siddiqui is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.