I want to extract the file through HTML and AngularJS to Java Spring with Hibernate. So, for example I've got in my HTML just:
<button type="button" class="btn btn-success btn-lg" ng-click="sendMail()">
<span class="glyphicon glyphicon glyphicon-send"></span> Wyślij
</button>
<input type="file" file-upload multiple name="file"/>
<button ng-click="add()">Add</button>
And i guess that's all for HTML.
JS file:
$scope.sendMail = function(){
$scope.emailData = new EmailData();
$scope.emailData.to = "konrad@gmail.com";
$scope.emailData.from = "emergency@gmail.com";
$scope.emailData.subject = "Sending maila";
$scope.emailData.type = "Sending failure";
$scope.emailData.title = $scope.data.title;
$scope.emailData.descriptMail = $scope.data.description;
$scope.emailData.description = "Chrome 5.4.0";
$http.post("sendemail", $scope.emailData, {headers: {'Content-Type':'application/json'} })
.then(function (response) {
$scope.succes = true;
},
function(fail) {
$scope.error = true;
});
}
So, how can I get this file which i drop and click add? I wanted, just like with other datas take $scope.emailData.attachement = "";
to use this in my Spring file.
Example:
in js I've got $scope.emailData.description = "Chrome 5.4.0";
and I can get it by spring:
private String description; and stuff with getters and setters
and then I can use it.
I'm not good in Spring and backend (yet), so that's why I am asking you