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
Asked
Active
Viewed 889 times
1
-
Is this your question? https://stackoverflow.com/questions/43823289/how-to-import-image-svg-png-in-a-react-component – фuɔumж εvоıqжʎuɯɹфʚd Feb 05 '22 at 16:18
1 Answers
1
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

amir
- 300
- 3
- 10