'How to show the image from the local file path example from c:/foldername/x.png
I would like to show the image from the File path example from c:/foldername/x.png. When I have given file path, we are getting cross mark but it is not loading the image, anyone has any idea? Code which I was working
<Image source={require('C:/Users/username/Pictures/66.png')}
style={{
width:220,
height:220,
borderWidth:2,
borderColor:'#d35647',
resizeMode:'stretch',
margin:8
}}
/>
Solution 1:[1]
If you have for example, the follow scafolding
src
|____/assets
|_________imgs
|_____________mi-img.png
|____/components
|_________/MyImage
|_____________MyComponent.js
in MyComponent.js you must access to your image in the follow way:
<Image source={require('../../assets/imgs/mi-img.png')}
style={{
width:220,
height:220,
borderWidth:2,
borderColor:'#d35647',
resizeMode:'stretch',
margin:8
}}
/>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | enzou |
