angular-base64-upload
angular-base64-upload copied to clipboard
$http Upload
Hi all, Using this directive, I can see how it outputs to base64, but am confused on how to pass this into my $http post as it is currently uploading a "corrupted" image file via SharePoint's REST API. HTML:
<form>
<input type="file" data-ng-model="files" base-sixty-four-input>
<button data-ng-click="upload()">Submit</button>
</form>
Upload Function:
$scope.upload = function () {
console.log($scope.files);
$http.post("/sites/ens/_api/web/lists/getByTitle('Report Images')/RootFolder/Files/add(url='" + $scope.files.filename + "',overwrite='true')", $scope.files.base64,
{
headers: {
'X-RequestDigest': $("#__REQUESTDIGEST").val(),
}
}).success(function (d) {
console.log(d);
});
}
This is specific to SharePoint's REST API. I have no experience with it. Ask this question to other Sharepoint discussion group or Stackoverflow.
Beyond SharePoint, are you passing $scope.files.base64 (assuming files is the name of the model). Or are you constructing a longer variable with data:image/type;base64,xxxxxxx
console.log($scope.files);
and you will see the data structure. It's up to you how to upload that to Sharepoint API.
Thank you