简体   繁体   English

HTTP错误403.14-上传文件angularjs时禁止

[英]HTTP Error 403.14 - Forbidden when uploading file angularjs

I am creating a web app in which I am storing user images in my folder, after a while I found an example which helps me, 我创建了一个网络应用程序,将用户图像存储在文件夹中,过了一会儿,我发现了一个可以帮助我的示例,

but I am getting the error 但我得到了错误

HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory. HTTP错误403.14-禁止Web服务器配置为不列出此目录的内容。

and my code is 我的代码是

source 资源

<head>
    <title></title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.js"></script>
    <script src="https://angular-file-upload.appspot.com/js/ng-file-upload-shim.js"></script>
    <script src="https://angular-file-upload.appspot.com/js/ng-file-upload.js"></script>
</head>

body 身体

<div ng-app="myApp" ng-controller="myCtrl">
        <input type="file" file-model="myFile" />
        <button ng-click="uploadFile()">upload me</button>
        <a href="#" ng-click="a()">save</a>
    </div>

script 脚本

 <script>
        //inject angular file upload directives and services.
        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.a = function () {
                console.log('called');
            }
            $scope.uploadFile = function () {
                console.log('called');
                var file = $scope.myFile;
                console.log('file is ');
                console.dir(file);
                var uploadUrl = "http://localhost:9206//file//";
                fileUpload.uploadFileToUrl(file, uploadUrl);
            };
        }]);

    </script>

and the url is 网址是

http://localhost:9206//file// HTTP://本地主机:9206 // //文件

let me explain this 让我解释一下

this is my one page application, I want to save image in my folder called file, 这是我的一页应用程序,我想将图像保存在名为file的文件夹中,

when a user uploaded his/her image, the image should be stored in the folder, 当用户上传他/她的图片时,该图片应存储在文件夹中,

but instead of this I am getting this error 但是相反,我得到这个错误

(HTTP Error 403.14 - Forbidden) (HTTP错误403.14-禁止)

what I need to do now? 我现在需要做什么?

It appears that the problem can be fixed by enabling the IIS. 看来可以通过启用IIS来解决此问题。 You can enable and configure the Internet Information Service (IIS) on your computer (given that you are using localhost) by following the instructions on this link: https://msdn.microsoft.com/en-us/library/ms181052(v=vs.80).aspx 您可以按照以下链接上的说明在计算机上启用和配置Internet信息服务(IIS)(如果您使用的是localhost): https : //msdn.microsoft.com/zh-cn/library/ms181052(v = VS.80)的.aspx

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

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