Zaw Than oo
Zaw Than oo

Reputation: 9935

Angularjs Fileupload change upload URL?

I use angular to upload the file as below :

If I run the following code, I get 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'
    });
},
...

In debugger console

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

When I change the code as below, it is OK.

...
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'
    });
},
...

Upvotes: 2

Views: 527

Answers (0)

Related Questions