Suppose I have to take an image from my local path & the path value is coming from API and I have taken that path in constant and trying to add that path in my image src to show on the page.
Example:
import React, {Component} from 'react';
class ImageElement extends Component {
static displayName = 'ImageElement';
render() {
const {element:{defaultPath, height, width}} = this.props;
const imagePath = 'E:/myPic/IMG_20191221_204716.jpg';
return (
<div>
<img
src={imagePath}
height={height}
width={width}
/>
</div>
);
}
}
export default ImageElement;
Chrome is throwing an error like Not allowed to load local resource: file:///E:/myPic/IMG_20191221_204716.jpg
I have tried different options as suggested by other users like
- Spanning a local server and then try to access file then
- c:\Program Files (x86)\google\chrome\Application\chrome.exe --allow-file-access-from-files
The first option works but is not useful in my use case the second one doesn't work at all. also tried installing some plugin and all do not work.
Any further guidance is appreciated.