如何上载公用文件夹中的图像并在Angularjs平均堆栈中检索它

如何上载公用文件夹中的图像并在Angularjs平均堆栈中检索它,angularjs,mongodb,mean-stack,image-uploading,Angularjs,Mongodb,Mean Stack,Image Uploading,我正在使用angularjs,我正在尝试进行上传图像操作。但我无法在本地路径中存储图像。我想将图像路径存储到我的数据库中,并且我正在使用mongodb上载图像操作。但我无法在本地路径中存储图像并从中检索。有人帮助我如何实现此功能吗 我的代码 你不能使用库吗?你只想上传一个文件夹并检索?是的,我将图像上传到公用文件夹并将其存储到数据库中该路径,然后我检索itany idea@SajeethandID你找到解决方案了吗?你不能使用库吗?你只想上传一个文件夹并检索吗?是的,我将图像上传到公用文件夹并将

我正在使用angularjs,我正在尝试进行上传图像操作。但我无法在本地路径中存储图像。我想将图像路径存储到我的数据库中,并且我正在使用mongodb上载图像操作。但我无法在本地路径中存储图像并从中检索。有人帮助我如何实现此功能吗

我的代码
你不能使用库吗?你只想上传一个文件夹并检索?是的,我将图像上传到公用文件夹并将其存储到数据库中该路径,然后我检索itany idea@SajeethandID你找到解决方案了吗?你不能使用库吗?你只想上传一个文件夹并检索吗?是的,我将图像上传到公用文件夹并将其存储到数据库中该路径,然后我检索itany idea@Sajeetharandid你找到解决方案了吗
<html>

   <head>
      <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
   </head>

   <body ng-app = "myApp">

    <div ng-controller = "myCtrl">
    <input type="file" file-model="myFile"/>
    <button ng-click="uploadFile()">upload me</button>
</div>

      <script>  
      var myApp = angular.module('myApp', []);

myApp.directive('fileModel', ['$parse', function ($parse) {
    return {
        restrict: 'A',
        link: function(scope, element, attrs) {
            var model = $parse(attrs.fileModel);
            var modelSetter = model.assign;

            element.bind('change', function(){
                scope.$apply(function(){
                    modelSetter(scope, element[0].files[0]);
                });
            });
        }
    };
}]);

myApp.service('fileUpload', ['$http', function ($http) {
    this.uploadFileToUrl = function(file, uploadUrl){
        var fd = new FormData();
        fd.append('file', file);
        $http.post(uploadUrl, fd, {
            transformRequest: angular.identity,
            headers: {'Content-Type': undefined}
        })
        .success(function(){
        })
        .error(function(){
        });
    }
}]);

myApp.controller('myCtrl', ['$scope', 'fileUpload', function($scope, fileUpload){

    $scope.uploadFile = function(){
        var file = $scope.myFile;
        console.log('file is ' );
        console.dir(file);
        var uploadUrl = "/public/fileUpload";
        fileUpload.uploadFileToUrl(file, uploadUrl);
    };

}]);

      </script>

   </body>
</html>
Not allowed to load local resource: file:///C:/Users/admin/Desktop/Delivery%20Architecture.jpg