angular-file-upload icon indicating copy to clipboard operation
angular-file-upload copied to clipboard

Upload content of a file instead of the file itself

Open thrinay opened this issue 8 years ago • 2 comments

I would like to upload contents of a .json file instead of file. I tried multiple ways to figure it out but couldn't find any solution despite. Thus would be glad if this is said. Thanks

thrinay avatar Jan 02 '18 15:01 thrinay

For those of you who are struggling to upload a JSON data instead of file. Kindly do the following.

var uploader = $scope.uploader = new FileUploader({});

uploader.uploadItem = function (item) { var reader = new FileReader(); reader.readAsBinaryString(item._file);

       reader.onloadend = function(){

         item.data = reader.result;
      }

// Here you can add item.data into your request body. };

Kindly close this issue as it's solved

thrinay avatar Jan 04 '18 11:01 thrinay

Kindly close this issue as it's solved

Done =)

nervgh avatar Jan 07 '18 08:01 nervgh