简体   繁体   中英

Saving file with angular-file-upload

I use angular-file-upload in my application in order to save a file.

I have the next code:

$scope.submitForm = function(valid, commit, file) {
    file.upload = Upload.upload({
        url: '/tmp',
        data: {file: file, username: $scope.username},
    });
    file.upload.then(function (response) {
        console.log(response);
    }, function (response) {
        console.log(response);
    }, function(env){
        console.log(env);
    })

The application is running on my machine, and I want that the file will save on the /tmp folder. The problem is that when I write tmp , it search the address /tmp , and not the location /tmp . How can I save the file without call to API?

You can't save files on server from client side without going though some kind of backend.

Angular file uploader sends a HTTP request to "url", in this case it tries to send to /tmp which most likely don't point to anything

In this case the client is trying to find that url in the server, which is not your case, you may need to develop a backend part too.

For testing purposes, remember you can use $httpbackend to fake HTTP backend implementation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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