Yash Mathur
Yash Mathur

Reputation: 111

How to import image from external folders in react

am a newbie in react and want to import an image from outside the root folder of project but react is not allowing me and i know can put those images inside public folder and can easily import them but only want to import them from outside directories

Upvotes: 1

Views: 1165

Answers (1)

Amirreza
Amirreza

Reputation: 463

You can not access outside the root folder in production, because your project is in the root directory of the server

if you want to access that file you create a virtual server that have access to that folder 📂 then you easily can access the img :

   <img src={"localhost:8080/img.png"} />

If you tell us more maybe we can give you another solution.

Edit : this is not just about images you do not have access to anything out of root directory using import or require

Upvotes: 1

Related Questions