1208_ Sagar Kapoor
1208_ Sagar Kapoor

Reputation: 9

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

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);

Upvotes: 0

Views: 23

Answers (1)

DevHasnain
DevHasnain

Reputation: 1

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

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

Upvotes: 0

Related Questions