Sign up ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.

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
};
share|improve this question

1 Answer 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/';
} );
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.