Home > Software engineering >  Express.js and ejs directory of folder
Express.js and ejs directory of folder

Time:11-22

I want to insert this image which is located here: images/image.png My main/start file is here: server.js my routes are here: routes/main.js my ejs file where I want to insert the image is here: views/main/index.ejs What directory do I have to use to get the image?

I tried to go from the ejs file: ../../images/image.png I tried to go from my routes: ../images/image.png And I tried to go from the main file ./images/image.png but nothing worked

<img src="../../images/image.png" alt="Cuold not load image">

enter image description here

Then in your index.ejs file. Add this codes to retrieve image.

<img src="/images/image.png" alt="your image">
  • Related