A simple file upload not working

I am struggling for the past 2 days to do a simple file upload. Nothing works for me based on the document and I am not sure who to proceed. I am done with all my application migration except this upload piece of functionality.

var savedFile = Backendless.Files.upload($scope.fileObj, "media", true, new Backendless.Async(uploadOK, uploadFail));


    var uploadOK = function(result) {
        console.log("result : " + result);


        console.log("File successfully uploaded. Path to download: " + result.fileURL);


        var blouseObject = new Blouse();


        blouseObject.notes = $scope.comments;
        blouseObject.user = Backendless.UserService.getCurrentUser();
        blouseObject.approved = 0;
        blouseObject.picture = result.fileURL;


        var savedObj = Backendless.Persistence.of(Blouse).save(blouseObject);
    }


    var uploadFail = function(result) {
        console.log("error - " + result.message);
    }

There are no errrors in the console as well. But the file is not uploaded or not the console log messages are shown. I believe the uploadOK function is never called.

I am referring to https://backendless.com/documentation/files/js/files_file_upload.htm

Finally fount the issue after posting this. What a luck :slight_smile:

There is inconsistent usage of “overwrite” parameter in the example and function signature in the docs.

Hi there,

the mistake caused your error is that the callback functions are declared with ‘var’ after the call.

Regards,
Stanislav