2017-08-11 55 views
0

我有一个应用程序,我在数据库中存储图像路径。路径是相对于我的文件系统而不是项目。ReactJS从项目外的文件系统加载图像

当我问题阵营:

<img alt={this.props.alt} src={require('/fs/storage/images/logo.jpg')}/> 

I'm收到以下错误:

You attempted to import /fs/storage/images/logo.jpg which falls outside of the project 
src/ directory. Relative imports outside of src/ are not supported. 
You can either move it inside src/, or add a symlink to it from project's node_modules. 

我该如何解决呢?我应该在哪里放置该消息所建议的符号链接?

+0

*的JavaScript。 –

回答

0

如何在客户端读取文件系统或数据库? 你有服务器吗?与数据库通信?

你应该在服务器中读取图像和发送的客户端,在那里用它起反应,因此运行在客户端浏览器*没有访问文件系统