显示存储在数据库

时间:2017-11-03 03:22:43

标签: node.js angular express

我需要在ngFor中显示相关图像

喜欢

<div class="row" *ngFor="let name of cheaterNames">
   <div class="col-4">
      {{ name.name }}
      <img src="{{name.path}}" class="rounded mx-auto d-block">
    </div>
</div>

这是数据库中数据的样子

  _id        OgjectId("566666tyyhhhh")
   name      Laravel
   path      uploads\logo.png

这是我的项目文件夹的样子

 Project
    client
      about
        about.component.html // this the html i used to display images
        about.component.ts
    dist
    e2e
    node_modules
    server //this is where express/nodejs
       controllers
       models
       routes
       app.ts 
    uploads // this is where the images is stored during file uploads
      logo.png
      other imgs...

对此有何想法?图像未显示并显示404错误

1 个答案:

答案 0 :(得分:0)

您的路径将全部相对于您的Web服务器的基本内容目录,该目录可能不是您项目的主目录。基本上, uploads 目录不在您的基本内容目录中,因此服务器在运行时将找不到您的图像文件。您需要确定基本内容目录的位置(快速服务器配置)并确保上载目录位于该目录下。

&#xA;&#xA;

例如,如果您正在提供服务来自 dist 目录的构建, uploads 应该在 dist ;

&#xA;
相关问题