0

I'm trying to upload file to Dropbox with following code. File is successfully uploaded to Dropbox but size gone 0 bytes.

I'm now planning to upload microsoft word and pdf file.

    $scope.uploadHtmlFile = function($files) {
        var data = $files;
        $http({
            method: 'PUT',
            url: 'https://api-content.dropbox.com/1/files_put/dropbox/' + $files[0].name + '?access_token=TOKEN',
            data: data
        }).success(function(data, status, headers, config) {
            console.log(data);
            console.log('file uploaded successfully');
        }).error(function(data, status, headers, config) {
            console.log('error : ' + data);
            console.log('erro file uploaded successfully');
        });
    }
PPShein
  • 13,309
  • 42
  • 142
  • 227

1 Answers1

0

$files is an array object, and file will be referred using $files[0].

$scope.uploadHtmlFile = function($files) {
        var data = $files[0];
        $http({
            method: 'PUT',
            url: 'https://api-content.dropbox.com/1/files_put/dropbox/' + $files[0].name + '?access_token=TOKEN',
            data: data
        }).success(function(data, status, headers, config) {
            console.log(data);
            console.log('file uploaded successfully');
        }).error(function(data, status, headers, config) {
            console.log('error : ' + data);
            console.log('erro file uploaded successfully');
        });
    }
Sheetal
  • 1,368
  • 1
  • 9
  • 15