1

Here is a module, that I use for my project https://github.com/nervgh/angular-file-upload
It works fine, if I'm adding URL when it create.
But, if I need to change that url after some time (before image was uploaded, but after it was initialized) - it's does not work.
See code

$scope.uploader = new FileUploader({
    url: '/default_url/' //set default url
});
$scope.changeURL = function(){
    // I thougth it should work, but not
    $scope.uploader.url = '/new_cool_url/';

    //recomended way from FAQ
    $scope.uploader.onBeforeUploadItem(function(item) {
        item.url = '/new_cool_url/';
    } );

    $scope.uploader.uploadAll(); // uploading to default_url
};

1 Answer 1

1

Take onBeforeUploadItem out from the changeURL function. Do something like this:

$scope.uploader = new FileUploader({
    url: '/default_url/' //set default url
});

$scope.uploader.onBeforeUploadItem(function(item) {
    item.url = '/new_cool_url/';
} );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.