简体   繁体   English

访问客户端的根文件夹

[英]access to the root folder for client side

I'm new in the development of server-side applications. 我是服务器端应用程序开发的新手。 I have a collection in mongodb which stores names of files that store in the root directory /uploads . 我在mongodb中有一个集合,该集合存储存储在根目录/uploads的文件的名称。 I have to download them on client side using the angular. 我必须使用angular在客户端下载它们。 But using the ng-src or simple src out of ng-repeat I get a 404 error. 但是从ng-repeat使用ng-src或简单的src会出现404错误。 Is there any way to get the client-side access to the directory with the files? 有什么方法可以让客户端访问带有文件的目录?

<div class="row jumbotron" ng-repeat="item in items">
    <div class="col-sm-1">
        <img ng-src="../../../uploads/{{item.logo}}">
    </div>
    <div class="col-sm-8">
        <h4>{{item.name}}</h4>
    </div>
    <div class="col-sm-2 pull-right">
        <button type="button" class="btn btn-lg btn-info" ng-click="showModal($index)">Edit</button>
    </div>
</div>

应用架构

Also tried to provided file through ../ - 404 (Not Found) 还尝试通过../提供文件(未找到)

<div>
    <img src="../../../uploads/38809344bac1a3a77c5d1e0493763849.png">
</div>

The path you provided will go up three folders and then will look for the uploads folder, as each ../ means: Go up one level ( relative path notation ). 您提供的路径将上升到三个文件夹,然后将查找上载文件夹,因为每个../表示:上升一个级别( 相对路径表示法 )。 If this is not the case, please update the question with a sample of your folder structure. 如果不是这种情况,请使用您的文件夹结构示例更新问题。 Relative paths start from the current folder in which your HTML file resides on the server. 相对路径从您的HTML文件在服务器上所在的当前文件夹开始。

Another point to keep in mind: If you're using Linux , The privileges of the /uploads folder must allow the application to access it. 需要记住的另一点:如果使用Linux ,则/uploads文件夹的特权必须允许应用程序访问它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM