2

我使用角度上传文件如下:

如果我运行以下代码,我会得到403(Forbidden)

var contextRoot = "http://localhost\\:6060/nomunoli";
...
...
uploadFile : function(taglist, description, userid, file) {
    return $upload.upload({
        url : contextRoot + "/auth/insertNMNL001FUN02",
        fields : {
            'description' : description,
            'userId' : userid,
            'tagList' : taglist,
        },
        file : file,
        fileFormDataName : 'file'
    });
},
...

在调试器控制台中

POST http://localhost/:6060/nomunoli/auth/insertNMNL001FUN02 403 (Forbidden)
    b   @   angular.min.js:79
    s   @   angular.min.js:74
    c.$get.f    @   angular.min.js:71
    l.promise.then.J    @   angular.min.js:101
    (anonymous function)    @   angular.min.js:102
    a.$get.h.$eval  @   angular.min.js:113
    a.$get.h.$digest    @   angular.min.js:110
    a.$get.h.$apply @   angular.min.js:113
    (anonymous function)    @   angular.min.js:195
    n.event.dispatch    @   jquery-2.1.3.min.js:3
    n.event.add.r.handle    @   jquery-2.1.3.min.js:3

当我如下更改代码时,就可以了。

...
uploadFile : function(taglist, description, userid, file) {
    return $upload.upload({
        url : "http://localhost\\:6060/nomunoli/auth/insertNMNL001FUN02",
        fields : {
            'description' : description,
            'userId' : userid,
            'tagList' : taglist,
        },
        file : file,
        fileFormDataName : 'file'
    });
},
...
4

0 回答 0