Multer is Not adding/showing image in public/assests when hosted

23 Views Asked by At

Actually when i tried to add image on localhost (on my machine) it is adding images to public/assests folder and showing those images but images are not adding or showing when i hosted it on render

app.use("/assets", express.static(path.join(\__dirname, "public/assets")));


const storage = multer.diskStorage({
  destination: function (req, file, cb) {
    cb(null, "public/assets");
  },
  filename: function (req, file, cb) {
    cb(null, file.originalname);
  },
});
const upload = multer({ storage });

app.post("/auth/register", upload.single("picture"), register);
1

There are 1 best solutions below

0
DevHasnain On

If you are using jade add the image to the HTML like this,

img(src='/assets/Screenshot 2024-02-11 003339.png', alt='Image')