Support Topics Documentation Slack YouTube Blog

Uncaught [object Object] error in angularjs fileupload call

Hi
I used following angular 1 code but I was not able to upload image file also I used the latest Js sdk . error is:
Uncaught [object Object]
Failed to load resource: the server responded with a status of 400 (Bad Request)

angular.module('webCert.newUser.Register', [])
 .controller('newUserController', function ($scope) {
 var files;
 var user = new Backendless.User();
 $scope.fileNameChanged = function (ele) {
 files = ele.files[0];
 console.log("file name changed" + files.size);
 }
 $scope.registerUser = function() {
 if ($scope.userkind == "Process Engineering") {
 uploadFileFunc();
 } else {
 user.name = $scope.name;
 user.password = $scope.password;
 user["usertype"] = $scope.usertype;
 user["signatureimageurl"] = "imageurl";
 Backendless.UserService.register(user, new Backendless.Async(userRegistered, gotError));
 }
 }
 function uploadFileFunc() {
 console.log("file in upload func" + files.size);
 var callback = {};
 callback.success = function (result) {
 $scope.registerUser = regUser(result.fileURL);
 console.log("File successfully uploaded. Path to download: " + result.fileURL);
 }
 callback.fault = function (result) {
 console.log(result.message);
 }
 Backendless.Files.upload(files, "signatureImages", callback);
 }
 function regUser(imageurl) {
 user.name = $scope.name;
 user.password = $scope.password;
 user["usertype"] = $scope.usertype;
 user["signatureimageurl"] = imageurl;
 Backendless.UserService.register(user, new Backendless.Async(userRegistered, gotError));
 }
 function userRegistered(user) {
 console.log("user has been registered");
 }
 function gotError(err) {
 console.log("error message - " + err.message);
 console.log("error code - " + err.statusCode);
 }
 })




html part is:


<input type="file" onchange="angular.element(this).scope().fileNameChanged(this)" name="..." accept="image/*"></span>

Hi

problem was in the path name. I added / before folder name the problem solved

i have same problem